mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
Merge branch 'master' into primitive_restart
Conflicts: Source/Core/VideoCommon/Src/VideoConfig.h Source/Plugins/Plugin_VideoDX9/Src/main.cpp Source/Plugins/Plugin_VideoOGL/Src/Render.cpp
This commit is contained in:
@ -199,6 +199,7 @@
|
||||
<ClCompile Include="Src\FramebufferManager.cpp" />
|
||||
<ClCompile Include="Src\main.cpp" />
|
||||
<ClCompile Include="Src\NativeVertexFormat.cpp" />
|
||||
<ClCompile Include="Src\PerfQuery.cpp" />
|
||||
<ClCompile Include="Src\PixelShaderCache.cpp" />
|
||||
<ClCompile Include="Src\Render.cpp" />
|
||||
<ClCompile Include="Src\stdafx.cpp">
|
||||
@ -222,6 +223,7 @@
|
||||
<ClInclude Include="Src\FramebufferManager.h" />
|
||||
<ClInclude Include="Src\Globals.h" />
|
||||
<ClInclude Include="Src\main.h" />
|
||||
<ClInclude Include="Src\PerfQuery.h" />
|
||||
<ClInclude Include="Src\PixelShaderCache.h" />
|
||||
<ClInclude Include="Src\Render.h" />
|
||||
<ClInclude Include="Src\stdafx.h" />
|
||||
|
@ -39,6 +39,9 @@
|
||||
<ClCompile Include="Src\TextureConverter.cpp">
|
||||
<Filter>D3D</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Src\PerfQuery.cpp">
|
||||
<Filter>Render</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Src\Globals.h" />
|
||||
@ -78,6 +81,9 @@
|
||||
<ClInclude Include="Src\TextureConverter.h">
|
||||
<Filter>D3D</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Src\PerfQuery.h">
|
||||
<Filter>Render</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="D3D">
|
||||
|
@ -114,9 +114,9 @@ private:
|
||||
color_surface_Format(D3DFMT_UNKNOWN), depth_surface_Format(D3DFMT_UNKNOWN),
|
||||
depth_ReadBuffer_Format(D3DFMT_UNKNOWN) {}
|
||||
|
||||
LPDIRECT3DTEXTURE9 color_texture;//Texture thats contains the color data of the render target
|
||||
LPDIRECT3DTEXTURE9 color_texture;//Texture that contains the color data of the render target
|
||||
LPDIRECT3DTEXTURE9 colorRead_texture;//1 pixel texture for temporal data store
|
||||
LPDIRECT3DTEXTURE9 depth_texture;//Texture thats contains the depth data of the render target
|
||||
LPDIRECT3DTEXTURE9 depth_texture;//Texture that contains the depth data of the render target
|
||||
LPDIRECT3DTEXTURE9 depthRead_texture;//4 pixel texture for temporal data store
|
||||
|
||||
LPDIRECT3DTEXTURE9 color_reinterpret_texture;//buffer used for ReinterpretPixelData
|
||||
@ -126,8 +126,8 @@ private:
|
||||
LPDIRECT3DSURFACE9 color_surface;//Color Surface
|
||||
LPDIRECT3DSURFACE9 color_ReadBuffer;//Surface 0 of colorRead_texture
|
||||
LPDIRECT3DSURFACE9 depth_ReadBuffer;//Surface 0 of depthRead_texture
|
||||
LPDIRECT3DSURFACE9 color_OffScreenReadBuffer;//System memory Surface that can be locked to retriebe the data
|
||||
LPDIRECT3DSURFACE9 depth_OffScreenReadBuffer;//System memory Surface that can be locked to retriebe the data
|
||||
LPDIRECT3DSURFACE9 color_OffScreenReadBuffer;//System memory Surface that can be locked to retrieve the data
|
||||
LPDIRECT3DSURFACE9 depth_OffScreenReadBuffer;//System memory Surface that can be locked to retrieve the data
|
||||
|
||||
D3DFORMAT color_surface_Format;//Format of the color Surface
|
||||
D3DFORMAT depth_surface_Format;//Format of the Depth Surface
|
||||
|
@ -187,7 +187,7 @@ void D3DVertexFormat::SetupVertexPointers()
|
||||
if (d3d_decl)
|
||||
DX9::D3D::SetVertexDeclaration(d3d_decl);
|
||||
else
|
||||
ERROR_LOG(VIDEO, "invalid d3d decl");
|
||||
ERROR_LOG(VIDEO, "Invalid D3D decl");
|
||||
}
|
||||
|
||||
} // namespace DX9
|
||||
|
155
Source/Plugins/Plugin_VideoDX9/Src/PerfQuery.cpp
Normal file
155
Source/Plugins/Plugin_VideoDX9/Src/PerfQuery.cpp
Normal file
@ -0,0 +1,155 @@
|
||||
#include "RenderBase.h"
|
||||
|
||||
#include "D3DBase.h"
|
||||
#include "PerfQuery.h"
|
||||
|
||||
namespace DX9 {
|
||||
|
||||
PerfQuery::PerfQuery()
|
||||
: m_query_read_pos()
|
||||
, m_query_count()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PerfQuery::~PerfQuery()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void PerfQuery::CreateDeviceObjects()
|
||||
{
|
||||
for (int i = 0; i != ARRAYSIZE(m_query_buffer); ++i)
|
||||
{
|
||||
D3D::dev->CreateQuery(D3DQUERYTYPE_OCCLUSION, &m_query_buffer[i].query);
|
||||
}
|
||||
ResetQuery();
|
||||
}
|
||||
void PerfQuery::DestroyDeviceObjects()
|
||||
{
|
||||
for (int i = 0; i != ARRAYSIZE(m_query_buffer); ++i)
|
||||
{
|
||||
m_query_buffer[i].query->Release();
|
||||
}
|
||||
}
|
||||
|
||||
void PerfQuery::EnableQuery(PerfQueryGroup type)
|
||||
{
|
||||
// Is this sane?
|
||||
if (m_query_count > ARRAYSIZE(m_query_buffer) / 2)
|
||||
WeakFlush();
|
||||
|
||||
if (ARRAYSIZE(m_query_buffer) == m_query_count)
|
||||
{
|
||||
// TODO
|
||||
FlushOne();
|
||||
ERROR_LOG(VIDEO, "Flushed query buffer early!");
|
||||
}
|
||||
|
||||
// start query
|
||||
if (type == PQG_ZCOMP_ZCOMPLOC || type == PQG_ZCOMP)
|
||||
{
|
||||
auto& entry = m_query_buffer[(m_query_read_pos + m_query_count) % ARRAYSIZE(m_query_buffer)];
|
||||
entry.query->Issue(D3DISSUE_BEGIN);
|
||||
entry.query_type = type;
|
||||
++m_query_count;
|
||||
}
|
||||
}
|
||||
|
||||
void PerfQuery::DisableQuery(PerfQueryGroup type)
|
||||
{
|
||||
// stop query
|
||||
if (type == PQG_ZCOMP_ZCOMPLOC || type == PQG_ZCOMP)
|
||||
{
|
||||
auto& entry = m_query_buffer[(m_query_read_pos + m_query_count + ARRAYSIZE(m_query_buffer)-1) % ARRAYSIZE(m_query_buffer)];
|
||||
entry.query->Issue(D3DISSUE_END);
|
||||
}
|
||||
}
|
||||
|
||||
void PerfQuery::ResetQuery()
|
||||
{
|
||||
m_query_count = 0;
|
||||
std::fill_n(m_results, ARRAYSIZE(m_results), 0);
|
||||
}
|
||||
|
||||
u32 PerfQuery::GetQueryResult(PerfQueryType type)
|
||||
{
|
||||
u32 result = 0;
|
||||
|
||||
if (type == PQ_ZCOMP_INPUT_ZCOMPLOC || type == PQ_ZCOMP_OUTPUT_ZCOMPLOC)
|
||||
{
|
||||
result = m_results[PQG_ZCOMP_ZCOMPLOC];
|
||||
}
|
||||
else if (type == PQ_ZCOMP_INPUT || type == PQ_ZCOMP_OUTPUT)
|
||||
{
|
||||
result = m_results[PQG_ZCOMP];
|
||||
}
|
||||
else if (type == PQ_BLEND_INPUT)
|
||||
{
|
||||
result = m_results[PQG_ZCOMP] + m_results[PQG_ZCOMP_ZCOMPLOC];
|
||||
}
|
||||
else if (type == PQ_EFB_COPY_CLOCKS)
|
||||
{
|
||||
result = m_results[PQG_EFB_COPY_CLOCKS];
|
||||
}
|
||||
|
||||
return result / 4;
|
||||
}
|
||||
|
||||
void PerfQuery::FlushOne()
|
||||
{
|
||||
auto& entry = m_query_buffer[m_query_read_pos];
|
||||
|
||||
DWORD result = 0;
|
||||
HRESULT hr = S_FALSE;
|
||||
while (hr != S_OK && hr != D3DERR_DEVICELOST)
|
||||
{
|
||||
// TODO: Might cause us to be stuck in an infinite loop!
|
||||
hr = entry.query->GetData(&result, sizeof(result), D3DGETDATA_FLUSH);
|
||||
}
|
||||
|
||||
// NOTE: Reported pixel metrics should be referenced to native resolution
|
||||
m_results[entry.query_type] += (u32)((u64)result * EFB_WIDTH / g_renderer->GetTargetWidth() * EFB_HEIGHT / g_renderer->GetTargetHeight());
|
||||
|
||||
m_query_read_pos = (m_query_read_pos + 1) % ARRAYSIZE(m_query_buffer);
|
||||
--m_query_count;
|
||||
}
|
||||
|
||||
// TODO: could selectively flush things, but I don't think that will do much
|
||||
void PerfQuery::FlushResults()
|
||||
{
|
||||
while (!IsFlushed())
|
||||
FlushOne();
|
||||
}
|
||||
|
||||
void PerfQuery::WeakFlush()
|
||||
{
|
||||
while (!IsFlushed())
|
||||
{
|
||||
auto& entry = m_query_buffer[m_query_read_pos];
|
||||
|
||||
DWORD result = 0;
|
||||
HRESULT hr = entry.query->GetData(&result, sizeof(result), 0);
|
||||
|
||||
if (hr == S_OK)
|
||||
{
|
||||
// NOTE: Reported pixel metrics should be referenced to native resolution
|
||||
m_results[entry.query_type] += (u32)((u64)result * EFB_WIDTH / g_renderer->GetTargetWidth() * EFB_HEIGHT / g_renderer->GetTargetHeight());
|
||||
|
||||
m_query_read_pos = (m_query_read_pos + 1) % ARRAYSIZE(m_query_buffer);
|
||||
--m_query_count;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool PerfQuery::IsFlushed() const
|
||||
{
|
||||
return 0 == m_query_count;
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
47
Source/Plugins/Plugin_VideoDX9/Src/PerfQuery.h
Normal file
47
Source/Plugins/Plugin_VideoDX9/Src/PerfQuery.h
Normal file
@ -0,0 +1,47 @@
|
||||
#ifndef _PERFQUERY_H_
|
||||
#define _PERFQUERY_H_
|
||||
|
||||
#include "PerfQueryBase.h"
|
||||
|
||||
namespace DX9 {
|
||||
|
||||
class PerfQuery : public PerfQueryBase
|
||||
{
|
||||
public:
|
||||
PerfQuery();
|
||||
~PerfQuery();
|
||||
|
||||
void EnableQuery(PerfQueryGroup type);
|
||||
void DisableQuery(PerfQueryGroup type);
|
||||
void ResetQuery();
|
||||
u32 GetQueryResult(PerfQueryType type);
|
||||
void FlushResults();
|
||||
bool IsFlushed() const;
|
||||
void CreateDeviceObjects();
|
||||
void DestroyDeviceObjects();
|
||||
|
||||
private:
|
||||
struct ActiveQuery
|
||||
{
|
||||
IDirect3DQuery9* query;
|
||||
PerfQueryGroup query_type;
|
||||
};
|
||||
|
||||
void WeakFlush();
|
||||
// Only use when non-empty
|
||||
void FlushOne();
|
||||
|
||||
// when testing in SMS: 64 was too small, 128 was ok
|
||||
static const int PERF_QUERY_BUFFER_SIZE = 512;
|
||||
|
||||
ActiveQuery m_query_buffer[PERF_QUERY_BUFFER_SIZE];
|
||||
int m_query_read_pos;
|
||||
|
||||
// TODO: sloppy
|
||||
volatile int m_query_count;
|
||||
volatile u32 m_results[PQG_NUM_MEMBERS];
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // _PERFQUERY_H_
|
@ -55,7 +55,7 @@
|
||||
#include "BPFunctions.h"
|
||||
#include "FPSCounter.h"
|
||||
#include "ConfigManager.h"
|
||||
|
||||
#include "PerfQuery.h"
|
||||
#include <strsafe.h>
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@ static u32 s_blendMode;
|
||||
static u32 s_LastAA;
|
||||
static bool IS_AMD;
|
||||
static float m_fMaxPointSize;
|
||||
|
||||
static bool s_vsync;
|
||||
static char *st;
|
||||
|
||||
static LPDIRECT3DSURFACE9 ScreenShootMEMSurface = NULL;
|
||||
@ -88,6 +88,7 @@ void SetupDeviceObjects()
|
||||
VertexShaderCache::Init();
|
||||
PixelShaderCache::Init();
|
||||
g_vertex_manager->CreateDeviceObjects();
|
||||
((PerfQuery*)g_perf_query)->CreateDeviceObjects();
|
||||
// Texture cache will recreate themselves over time.
|
||||
}
|
||||
|
||||
@ -100,6 +101,7 @@ void TeardownDeviceObjects()
|
||||
D3D::dev->SetRenderTarget(0, D3D::GetBackBufferSurface());
|
||||
D3D::dev->SetDepthStencilSurface(D3D::GetBackBufferDepthSurface());
|
||||
delete g_framebuffer_manager;
|
||||
((PerfQuery*)g_perf_query)->DestroyDeviceObjects();
|
||||
D3D::font.Shutdown();
|
||||
TextureCache::Invalidate();
|
||||
VertexLoaderManager::Shutdown();
|
||||
@ -190,7 +192,8 @@ Renderer::Renderer()
|
||||
D3D::dev->CreateOffscreenPlainSurface(s_backbuffer_width,s_backbuffer_height, D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, &ScreenShootMEMSurface, NULL );
|
||||
D3D::SetRenderState(D3DRS_POINTSCALEENABLE,false);
|
||||
m_fMaxPointSize = D3D::GetCaps().MaxPointSize;
|
||||
|
||||
// Handle VSync on/off
|
||||
s_vsync = g_ActiveConfig.IsVSync();
|
||||
}
|
||||
|
||||
Renderer::~Renderer()
|
||||
@ -452,7 +455,8 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data)
|
||||
}
|
||||
else if(type == PEEK_COLOR)
|
||||
{
|
||||
// TODO: Can't we directly StretchRect to System buf?
|
||||
// We can't directly StretchRect to System buf because is not supported by all implementations
|
||||
// this is the only safe path that works in most cases
|
||||
hr = D3D::dev->StretchRect(pEFBSurf, &RectToLock, pBufferRT, NULL, D3DTEXF_NONE);
|
||||
D3D::dev->GetRenderTargetData(pBufferRT, pSystemBuf);
|
||||
|
||||
@ -661,18 +665,18 @@ void Renderer::SetBlendMode(bool forceUpdate)
|
||||
// Our render target always uses an alpha channel, so we need to override the blend functions to assume a destination alpha of 1 if the render target isn't supposed to have an alpha channel
|
||||
// Example: D3DBLEND_DESTALPHA needs to be D3DBLEND_ONE since the result without an alpha channel is assumed to always be 1.
|
||||
bool target_has_alpha = bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24;
|
||||
//bDstAlphaPass is taked in account because the ability of disabling alpha composition is
|
||||
//really usefull for debuging shader and blending errors
|
||||
bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate && target_has_alpha;
|
||||
bool useDualSource = useDstAlpha && g_ActiveConfig.backend_info.bSupportsDualSourceBlend;
|
||||
//bDstAlphaPass is taken into account because the ability to disable alpha composition is
|
||||
//really useful for debugging shader and blending errors
|
||||
bool use_DstAlpha = !g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate && target_has_alpha;
|
||||
bool use_DualSource = use_DstAlpha && g_ActiveConfig.backend_info.bSupportsDualSourceBlend;
|
||||
const D3DBLEND d3dSrcFactors[8] =
|
||||
{
|
||||
D3DBLEND_ZERO,
|
||||
D3DBLEND_ONE,
|
||||
D3DBLEND_DESTCOLOR,
|
||||
D3DBLEND_INVDESTCOLOR,
|
||||
(useDualSource) ? D3DBLEND_SRCCOLOR2 : D3DBLEND_SRCALPHA,
|
||||
(useDualSource) ? D3DBLEND_INVSRCCOLOR2 : D3DBLEND_INVSRCALPHA,
|
||||
(use_DualSource) ? D3DBLEND_SRCCOLOR2 : D3DBLEND_SRCALPHA,
|
||||
(use_DualSource) ? D3DBLEND_INVSRCCOLOR2 : D3DBLEND_INVSRCALPHA,
|
||||
(target_has_alpha) ? D3DBLEND_DESTALPHA : D3DBLEND_ONE,
|
||||
(target_has_alpha) ? D3DBLEND_INVDESTALPHA : D3DBLEND_ZERO
|
||||
};
|
||||
@ -682,8 +686,8 @@ void Renderer::SetBlendMode(bool forceUpdate)
|
||||
D3DBLEND_ONE,
|
||||
D3DBLEND_SRCCOLOR,
|
||||
D3DBLEND_INVSRCCOLOR,
|
||||
(useDualSource) ? D3DBLEND_SRCCOLOR2 : D3DBLEND_SRCALPHA,
|
||||
(useDualSource) ? D3DBLEND_INVSRCCOLOR2 : D3DBLEND_INVSRCALPHA,
|
||||
(use_DualSource) ? D3DBLEND_SRCCOLOR2 : D3DBLEND_SRCALPHA,
|
||||
(use_DualSource) ? D3DBLEND_INVSRCCOLOR2 : D3DBLEND_INVSRCALPHA,
|
||||
(target_has_alpha) ? D3DBLEND_DESTALPHA : D3DBLEND_ONE,
|
||||
(target_has_alpha) ? D3DBLEND_INVDESTALPHA : D3DBLEND_ZERO
|
||||
};
|
||||
@ -696,7 +700,7 @@ void Renderer::SetBlendMode(bool forceUpdate)
|
||||
|
||||
bool blend_enable = bpmem.blendmode.subtract || bpmem.blendmode.blendenable;
|
||||
D3D::SetRenderState(D3DRS_ALPHABLENDENABLE, blend_enable);
|
||||
D3D::SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, blend_enable);
|
||||
D3D::SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, blend_enable && g_ActiveConfig.backend_info.bSupportsSeparateAlphaFunction);
|
||||
if (blend_enable)
|
||||
{
|
||||
D3DBLENDOP op = D3DBLENDOP_ADD;
|
||||
@ -711,24 +715,27 @@ void Renderer::SetBlendMode(bool forceUpdate)
|
||||
D3D::SetRenderState(D3DRS_BLENDOP, op);
|
||||
D3D::SetRenderState(D3DRS_SRCBLEND, d3dSrcFactors[srcidx]);
|
||||
D3D::SetRenderState(D3DRS_DESTBLEND, d3dDestFactors[dstidx]);
|
||||
if (useDualSource)
|
||||
{
|
||||
op = D3DBLENDOP_ADD;
|
||||
srcidx = GX_BL_ONE;
|
||||
dstidx = GX_BL_ZERO;
|
||||
}
|
||||
else
|
||||
if (g_ActiveConfig.backend_info.bSupportsSeparateAlphaFunction)
|
||||
{
|
||||
// we can't use D3DBLEND_DESTCOLOR or D3DBLEND_INVDESTCOLOR for source in alpha channel so use their alpha equivalent instead
|
||||
if (srcidx == GX_BL_DSTCLR) srcidx = GX_BL_DSTALPHA;
|
||||
if (srcidx == GX_BL_INVDSTCLR) srcidx = GX_BL_INVDSTALPHA;
|
||||
// we can't use D3DBLEND_SRCCOLOR or D3DBLEND_INVSRCCOLOR for destination in alpha channel so use their alpha equivalent instead
|
||||
if (dstidx == GX_BL_SRCCLR) dstidx = GX_BL_SRCALPHA;
|
||||
if (dstidx == GX_BL_INVSRCCLR) dstidx = GX_BL_INVSRCALPHA;
|
||||
}
|
||||
D3D::SetRenderState(D3DRS_BLENDOPALPHA, op);
|
||||
D3D::SetRenderState(D3DRS_SRCBLENDALPHA, d3dSrcFactors[srcidx]);
|
||||
D3D::SetRenderState(D3DRS_DESTBLENDALPHA, d3dDestFactors[dstidx]);
|
||||
if (use_DualSource)
|
||||
{
|
||||
op = D3DBLENDOP_ADD;
|
||||
srcidx = GX_BL_ONE;
|
||||
dstidx = GX_BL_ZERO;
|
||||
}
|
||||
else
|
||||
{
|
||||
// we can't use D3DBLEND_DESTCOLOR or D3DBLEND_INVDESTCOLOR for source in alpha channel so use their alpha equivalent instead
|
||||
if (srcidx == GX_BL_DSTCLR) srcidx = GX_BL_DSTALPHA;
|
||||
if (srcidx == GX_BL_INVDSTCLR) srcidx = GX_BL_INVDSTALPHA;
|
||||
// we can't use D3DBLEND_SRCCOLOR or D3DBLEND_INVSRCCOLOR for destination in alpha channel so use their alpha equivalent instead
|
||||
if (dstidx == GX_BL_SRCCLR) dstidx = GX_BL_SRCALPHA;
|
||||
if (dstidx == GX_BL_INVSRCCLR) dstidx = GX_BL_INVSRCALPHA;
|
||||
}
|
||||
D3D::SetRenderState(D3DRS_BLENDOPALPHA, op);
|
||||
D3D::SetRenderState(D3DRS_SRCBLENDALPHA, d3dSrcFactors[srcidx]);
|
||||
D3D::SetRenderState(D3DRS_DESTBLENDALPHA, d3dDestFactors[dstidx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1034,7 +1041,8 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
|
||||
DLCache::ProgressiveCleanup();
|
||||
TextureCache::Cleanup();
|
||||
|
||||
// Flip/present backbuffer to frontbuffer here
|
||||
D3D::Present();
|
||||
// Enable configuration changes
|
||||
UpdateActiveConfig();
|
||||
TextureCache::OnConfigChanged(g_ActiveConfig);
|
||||
@ -1093,8 +1101,15 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
// New frame
|
||||
stats.ResetFrame();
|
||||
|
||||
// Flip/present backbuffer to frontbuffer here
|
||||
D3D::Present();
|
||||
// Handle vsync changes during execution
|
||||
if(s_vsync != g_ActiveConfig.IsVSync())
|
||||
{
|
||||
s_vsync = g_ActiveConfig.IsVSync();
|
||||
TeardownDeviceObjects();
|
||||
D3D::Reset();
|
||||
// device objects lost, so recreate all of them
|
||||
SetupDeviceObjects();
|
||||
}
|
||||
D3D::BeginFrame();
|
||||
RestoreAPIState();
|
||||
|
||||
@ -1110,14 +1125,16 @@ void Renderer::ApplyState(bool bUseDstAlpha)
|
||||
{
|
||||
if (bUseDstAlpha)
|
||||
{
|
||||
// TODO: WTF is this crap? We're enabling color writing regardless of the actual GPU state here...
|
||||
// If we get here we are sure that we are using dst alpha pass. (bpmem.dstalpha.enable)
|
||||
// Alpha write is enabled. (because bpmem.blendmode.alphaupdate && bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24)
|
||||
// We must disable blend because we want to write alpha value directly to the alpha channel without modifications.
|
||||
D3D::ChangeRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA);
|
||||
D3D::ChangeRenderState(D3DRS_ALPHABLENDENABLE, false);
|
||||
if(bpmem.zmode.testenable && bpmem.zmode.updateenable)
|
||||
{
|
||||
//This is needed to draw to the correct pixels in multi-pass algorithms
|
||||
//this avoid z-figthing and grants that you write to the same pixels
|
||||
//affected by the last pass
|
||||
// This is needed to draw to the correct pixels in multi-pass algorithms
|
||||
// to avoid z-fighting and grants that you write to the same pixels
|
||||
// affected by the last pass
|
||||
D3D::ChangeRenderState(D3DRS_ZWRITEENABLE, false);
|
||||
D3D::ChangeRenderState(D3DRS_ZFUNC, D3DCMP_EQUAL);
|
||||
}
|
||||
@ -1310,7 +1327,7 @@ void Renderer::SetLineWidth()
|
||||
// We can't change line width in D3D unless we use ID3DXLine
|
||||
float fratio = xfregs.viewport.wd != 0 ? Renderer::EFBToScaledXf(1.f) : 1.0f;
|
||||
float psize = bpmem.lineptwidth.linesize * fratio / 6.0f;
|
||||
//little hack to compensate scalling problems in dx9 must be taken out when scalling is fixed.
|
||||
//little hack to compensate scaling problems in dx9 must be taken out when scaling is fixed.
|
||||
psize *= 2.0f;
|
||||
if (psize > m_fMaxPointSize)
|
||||
{
|
||||
|
@ -353,7 +353,7 @@ void VertexManager::vFlush()
|
||||
PixelShaderManager::SetTexDims(i, tentry->native_width, tentry->native_height, 0, 0);
|
||||
}
|
||||
else
|
||||
ERROR_LOG(VIDEO, "error loading texture");
|
||||
ERROR_LOG(VIDEO, "Error loading texture");
|
||||
}
|
||||
}
|
||||
|
||||
@ -378,7 +378,8 @@ void VertexManager::vFlush()
|
||||
|
||||
}
|
||||
PrepareDrawBuffers(stride);
|
||||
g_nativeVertexFmt->SetupVertexPointers();
|
||||
g_nativeVertexFmt->SetupVertexPointers();
|
||||
g_perf_query->EnableQuery(bpmem.zcontrol.early_ztest ? PQG_ZCOMP_ZCOMPLOC : PQG_ZCOMP);
|
||||
if(m_buffers_count)
|
||||
{
|
||||
DrawVertexBuffer(stride);
|
||||
@ -387,7 +388,7 @@ void VertexManager::vFlush()
|
||||
{
|
||||
DrawVertexArray(stride);
|
||||
}
|
||||
|
||||
g_perf_query->DisableQuery(bpmem.zcontrol.early_ztest ? PQG_ZCOMP_ZCOMPLOC : PQG_ZCOMP);
|
||||
if (useDstAlpha && !useDualSource)
|
||||
{
|
||||
if (!PixelShaderCache::SetShader(DSTALPHA_ALPHA_PASS, g_nativeVertexFmt->m_components))
|
||||
|
@ -57,7 +57,7 @@
|
||||
|
||||
#include "ConfigManager.h"
|
||||
#include "VideoBackend.h"
|
||||
#include "PerfQueryBase.h"
|
||||
#include "PerfQuery.h"
|
||||
|
||||
namespace DX9
|
||||
{
|
||||
@ -95,27 +95,17 @@ std::string VideoBackend::GetDisplayName()
|
||||
void InitBackendInfo()
|
||||
{
|
||||
DX9::D3D::Init();
|
||||
const int shaderModel = ((DX9::D3D::GetCaps().PixelShaderVersion >> 8) & 0xFF);
|
||||
D3DCAPS9 device_caps = DX9::D3D::GetCaps();
|
||||
const int shaderModel = ((device_caps.PixelShaderVersion >> 8) & 0xFF);
|
||||
const int maxConstants = (shaderModel < 3) ? 32 : ((shaderModel < 4) ? 224 : 65536);
|
||||
g_Config.backend_info.APIType = shaderModel < 3 ? API_D3D9_SM20 : API_D3D9_SM30;
|
||||
g_Config.backend_info.bUseRGBATextures = false;
|
||||
g_Config.backend_info.bUseMinimalMipCount = true;
|
||||
g_Config.backend_info.bSupports3DVision = true;
|
||||
g_Config.backend_info.bSupportsPrimitiveRestart = false; // TODO: figure out if it does
|
||||
OSVERSIONINFO info;
|
||||
ZeroMemory(&info, sizeof(OSVERSIONINFO));
|
||||
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
if (GetVersionEx(&info))
|
||||
{
|
||||
// dual source blending is only supported in windows 7 o newer. sorry xp users
|
||||
// we cannot test for device caps because most drivers just declare the minimun caps
|
||||
// and don't expose their support for some functionalities
|
||||
g_Config.backend_info.bSupportsDualSourceBlend = info.dwPlatformId == VER_PLATFORM_WIN32_NT && info.dwMajorVersion > 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_Config.backend_info.bSupportsDualSourceBlend = false;
|
||||
}
|
||||
g_Config.backend_info.bSupportsSeparateAlphaFunction = device_caps.PrimitiveMiscCaps & D3DPMISCCAPS_SEPARATEALPHABLEND;
|
||||
// Dual source blend disabled by default until a proper method to test for support is found
|
||||
g_Config.backend_info.bSupportsDualSourceBlend = false;
|
||||
g_Config.backend_info.bSupportsFormatReinterpretation = true;
|
||||
g_Config.backend_info.bSupportsPixelLighting = C_PLIGHTS + 40 <= maxConstants && C_PMATERIALS + 4 <= maxConstants;
|
||||
|
||||
@ -188,9 +178,9 @@ void VideoBackend::Video_Prepare()
|
||||
|
||||
// internal interfaces
|
||||
g_vertex_manager = new VertexManager;
|
||||
g_perf_query = new PerfQuery;
|
||||
g_renderer = new Renderer;
|
||||
g_texture_cache = new TextureCache;
|
||||
g_perf_query = new PerfQueryBase;
|
||||
g_texture_cache = new TextureCache;
|
||||
// VideoCommon
|
||||
BPInit();
|
||||
Fifo_Init();
|
||||
@ -200,8 +190,7 @@ void VideoBackend::Video_Prepare()
|
||||
PixelShaderManager::Init();
|
||||
CommandProcessor::Init();
|
||||
PixelEngine::Init();
|
||||
DLCache::Init();
|
||||
|
||||
DLCache::Init();
|
||||
// Notify the core that the video backend is ready
|
||||
Host_Message(WM_USER_CREATE);
|
||||
}
|
||||
@ -229,9 +218,9 @@ void VideoBackend::Shutdown()
|
||||
// internal interfaces
|
||||
PixelShaderCache::Shutdown();
|
||||
VertexShaderCache::Shutdown();
|
||||
delete g_perf_query;
|
||||
delete g_texture_cache;
|
||||
delete g_renderer;
|
||||
delete g_perf_query;
|
||||
delete g_vertex_manager;
|
||||
g_renderer = NULL;
|
||||
g_texture_cache = NULL;
|
||||
|
Reference in New Issue
Block a user