2009-07-28 21:32:10 +00:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
2009-04-03 14:35:49 +00:00
|
|
|
// ---------------------------------------------------------------------------------------------
|
2009-03-05 23:11:13 +00:00
|
|
|
// GC graphics pipeline
|
2009-04-03 14:35:49 +00:00
|
|
|
// ---------------------------------------------------------------------------------------------
|
2009-03-05 23:11:13 +00:00
|
|
|
// 3d commands are issued through the fifo. The gpu draws to the 2MB EFB.
|
|
|
|
// The efb can be copied back into ram in two forms: as textures or as XFB.
|
|
|
|
// The XFB is the region in RAM that the VI chip scans out to the television.
|
|
|
|
// So, after all rendering to EFB is done, the image is copied into one of two XFBs in RAM.
|
|
|
|
// Next frame, that one is scanned out and the other one gets the copy. = double buffering.
|
2009-04-03 14:35:49 +00:00
|
|
|
// ---------------------------------------------------------------------------------------------
|
2008-12-25 15:56:36 +00:00
|
|
|
|
2009-09-03 20:37:35 +00:00
|
|
|
#ifndef _COMMON_RENDER_H_
|
|
|
|
#define _COMMON_RENDER_H_
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2009-09-03 20:37:35 +00:00
|
|
|
#include "VideoCommon.h"
|
|
|
|
#include "MathUtil.h"
|
|
|
|
#include "pluginspecs_video.h"
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2009-09-13 17:46:33 +00:00
|
|
|
// TODO: Move these out of here.
|
2008-12-08 04:46:09 +00:00
|
|
|
extern int frameCount;
|
2009-06-08 02:48:38 +00:00
|
|
|
extern int OSDChoice, OSDTime, OSDInternalW, OSDInternalH;
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2009-09-13 17:46:33 +00:00
|
|
|
// Renderer really isn't a very good name for this class - it's more like "Misc".
|
|
|
|
// The long term goal is to get rid of this class and replace it with others that make
|
|
|
|
// more sense.
|
2008-12-08 04:46:09 +00:00
|
|
|
class Renderer
|
|
|
|
{
|
|
|
|
public:
|
2009-09-06 15:11:21 +00:00
|
|
|
static bool Init();
|
|
|
|
static void Shutdown();
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2009-09-03 19:24:16 +00:00
|
|
|
// What's the real difference between these? Too similar names.
|
2009-09-06 15:11:21 +00:00
|
|
|
static void ResetAPIState();
|
|
|
|
static void RestoreAPIState();
|
2009-02-21 13:11:49 +00:00
|
|
|
|
2009-09-06 15:11:21 +00:00
|
|
|
static void ReinitView();
|
2009-09-03 20:37:35 +00:00
|
|
|
|
2009-09-06 15:11:21 +00:00
|
|
|
static void SetColorMask();
|
2009-01-18 19:03:14 +00:00
|
|
|
static void SetBlendMode(bool forceUpdate);
|
2008-12-08 04:46:09 +00:00
|
|
|
static bool SetScissorRect();
|
2009-11-23 14:08:08 +00:00
|
|
|
static void SetGenerationMode();
|
|
|
|
static void SetDepthMode();
|
2009-11-27 19:42:27 +00:00
|
|
|
static void SetLogicOpMode();
|
|
|
|
static void SetDitherMode();
|
|
|
|
static void SetLineWidth();
|
|
|
|
static void SetSamplerState(int stage,int texindex);
|
|
|
|
static void SetInterlacingMode();
|
2009-09-06 15:11:21 +00:00
|
|
|
// Live resolution change
|
|
|
|
static bool Allow2x();
|
|
|
|
static bool AllowCustom();
|
|
|
|
|
2009-02-21 12:53:10 +00:00
|
|
|
// Render target management
|
2009-09-06 15:11:21 +00:00
|
|
|
static int GetFrameBufferWidth();
|
|
|
|
static int GetFrameBufferHeight();
|
|
|
|
static int GetCustomWidth();
|
|
|
|
static int GetCustomHeight();
|
|
|
|
static int GetTargetWidth();
|
|
|
|
static int GetTargetHeight();
|
ok big changes here:
in videocommon little fix for the alpha test values, return to the original values as they are more accurate.
in D3D:
huge change in state management, now all the state management is centralized and redundant state changes are eliminated.
Fixed the overlapped viewport error in non ati cards:
the error was caused by this: when a viewport is defined larger than the current rendertarget, an error is thrown and the last valid viewport is used, this is the reference behavior, in ati cards if a larger viewport is defined, no eror is returned, the rendering is valid and is rendered using the projection defined by the viewport but limited to the rendertarget are, exactly like opengl or the GC hardware.
to solve this in reference drivers defined a large rendertarget (2x the size of the original) and proceed to render in a centered quad insithe the larger rendertarget, in this way larger viewports always falls inside a valid rendertarget size, the drawback of this is the waste of resources. it can be dynamized, depending or games or changed at runtime when a oversized viewport is detected, but i live that to future commits.
please test this and let me know the results.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4841 8ced0084-cf51-0410-be5f-012b33b47a6e
2010-01-15 15:52:08 +00:00
|
|
|
static int GetFullTargetWidth();
|
|
|
|
static int GetFullTargetHeight();
|
2009-02-21 12:53:10 +00:00
|
|
|
|
2009-03-05 23:11:13 +00:00
|
|
|
// Multiply any 2D EFB coordinates by these when rendering.
|
2009-02-28 16:33:59 +00:00
|
|
|
static float GetTargetScaleX();
|
|
|
|
static float GetTargetScaleY();
|
|
|
|
|
2009-07-15 00:51:24 +00:00
|
|
|
static TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc);
|
|
|
|
|
|
|
|
static u32 AccessEFB(EFBAccessType type, int x, int y);
|
|
|
|
|
2009-02-21 12:53:10 +00:00
|
|
|
// Random utilities
|
|
|
|
static void RenderText(const char* pstr, int left, int top, u32 color);
|
2009-02-28 16:33:59 +00:00
|
|
|
static void DrawDebugText();
|
2009-02-27 03:56:34 +00:00
|
|
|
static void SetScreenshot(const char *filename);
|
2009-03-28 21:07:16 +00:00
|
|
|
static void FlipImageData(u8 *data, int w, int h);
|
2009-06-06 15:51:03 +00:00
|
|
|
static bool SaveRenderTarget(const char *filename, int w, int h, int YOffset = 0);
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2009-07-15 00:51:24 +00:00
|
|
|
static void ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z);
|
|
|
|
static void RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc);
|
2009-06-26 08:57:53 +00:00
|
|
|
|
2008-12-08 04:46:09 +00:00
|
|
|
// Finish up the current frame, print some stats
|
2009-07-11 02:34:16 +00:00
|
|
|
static void Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight);
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
|
|
|
|
2009-09-13 10:18:01 +00:00
|
|
|
void UpdateViewport();
|
|
|
|
|
2009-09-03 20:37:35 +00:00
|
|
|
#endif // _COMMON_RENDER_H_
|