Fix all remaining window resizing issues.
Implement screenshot functionality (doesn't seem to work completely, yet).
Assign debug names to (hopefully) all remaining device objects.
Flush the GPU's command buffer in Close() to make the ReportLiveDeviceObjects output clearer.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5730 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
NeoBrainX 2010-06-17 10:42:57 +00:00
parent 49674400e0
commit 91d540ad67
10 changed files with 84 additions and 25 deletions

View File

@ -91,7 +91,7 @@
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalOptions="&quot;..\..\core\common\win32\release\common.lib&quot;" AdditionalOptions="&quot;..\..\core\common\win32\release\common.lib&quot;"
AdditionalDependencies="odbc32.lib d3dcompiler.lib odbccp32.lib comctl32.lib dxguid.lib d3d11.lib dxgi.lib winmm.lib vfw32.lib wxbase28u.lib wxmsw28u_core.lib" AdditionalDependencies="odbc32.lib d3dcompiler.lib odbccp32.lib comctl32.lib dxguid.lib d3dx11.lib d3d11.lib dxgi.lib winmm.lib vfw32.lib wxbase28u.lib wxmsw28u_core.lib"
OutputFile="..\..\..\Binary\Win32\Plugins\Plugin_VideoDX11.dll" OutputFile="..\..\..\Binary\Win32\Plugins\Plugin_VideoDX11.dll"
LinkIncremental="1" LinkIncremental="1"
SuppressStartupBanner="true" SuppressStartupBanner="true"
@ -199,7 +199,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="odbc32.lib d3dcompiler.lib odbccp32.lib comctl32.lib dxguid.lib d3d11.lib dxgi.lib winmm.lib vfw32.lib wxbase28u.lib wxmsw28u_core.lib" AdditionalDependencies="odbc32.lib d3dcompiler.lib odbccp32.lib comctl32.lib dxguid.lib d3dx11.lib d3d11.lib dxgi.lib winmm.lib vfw32.lib wxbase28u.lib wxmsw28u_core.lib"
OutputFile="..\..\..\Binary\x64\Plugins\Plugin_VideoDX11.dll" OutputFile="..\..\..\Binary\x64\Plugins\Plugin_VideoDX11.dll"
LinkIncremental="1" LinkIncremental="1"
SuppressStartupBanner="true" SuppressStartupBanner="true"
@ -297,7 +297,7 @@
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalOptions="&quot;..\..\core\common\win32\debug\common.lib&quot;" AdditionalOptions="&quot;..\..\core\common\win32\debug\common.lib&quot;"
AdditionalDependencies="odbc32.lib d3dcompiler.lib odbccp32.lib comctl32.lib uuid.lib dxguid.lib d3d11.lib dxgi.lib Rpcrt4.lib winmm.lib vfw32.lib wxbase28ud.lib wxmsw28ud_core.lib" AdditionalDependencies="odbc32.lib d3dcompiler.lib odbccp32.lib comctl32.lib uuid.lib dxguid.lib d3dx11.lib d3d11.lib dxgi.lib Rpcrt4.lib winmm.lib vfw32.lib wxbase28ud.lib wxmsw28ud_core.lib"
OutputFile="..\..\..\Binary\Win32/Plugins\Plugin_VideoDX11D.dll" OutputFile="..\..\..\Binary\Win32/Plugins\Plugin_VideoDX11D.dll"
LinkIncremental="1" LinkIncremental="1"
SuppressStartupBanner="true" SuppressStartupBanner="true"
@ -393,7 +393,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="odbc32.lib d3dcompiler.lib odbccp32.lib comctl32.lib uuid.lib dxguid.lib d3d11.lib dxgi.lib Rpcrt4.lib winmm.lib vfw32.lib" AdditionalDependencies="odbc32.lib d3dcompiler.lib odbccp32.lib comctl32.lib uuid.lib dxguid.lib d3dx11.lib d3d11.lib dxgi.lib Rpcrt4.lib winmm.lib vfw32.lib"
OutputFile="..\..\..\Binary\x64\Plugins\Plugin_VideoDX11D.dll" OutputFile="..\..\..\Binary\x64\Plugins\Plugin_VideoDX11D.dll"
LinkIncremental="1" LinkIncremental="1"
SuppressStartupBanner="true" SuppressStartupBanner="true"
@ -499,7 +499,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="odbc32.lib d3dcompiler.lib odbccp32.lib comctl32.lib uuid.lib dxguid.lib d3d11.lib dxgi.lib Rpcrt4.lib winmm.lib vfw32.lib" AdditionalDependencies="odbc32.lib d3dcompiler.lib odbccp32.lib comctl32.lib uuid.lib dxguid.lib d3dx11.lib d3d11.lib dxgi.lib Rpcrt4.lib winmm.lib vfw32.lib"
OutputFile="..\..\..\Binary\Win32\Plugins\Plugin_VideoDX11DF.dll" OutputFile="..\..\..\Binary\Win32\Plugins\Plugin_VideoDX11DF.dll"
LinkIncremental="1" LinkIncremental="1"
SuppressStartupBanner="true" SuppressStartupBanner="true"
@ -608,7 +608,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="odbc32.lib d3dcompiler.lib odbccp32.lib comctl32.lib uuid.lib dxguid.lib d3d11.lib dxgi.lib Rpcrt4.lib winmm.lib vfw32.lib" AdditionalDependencies="odbc32.lib d3dcompiler.lib odbccp32.lib comctl32.lib uuid.lib dxguid.lib d3dx11.lib d3d11.lib dxgi.lib Rpcrt4.lib winmm.lib vfw32.lib"
OutputFile="..\..\..\Binary\x64\Plugins\Plugin_VideoDX11DF.dll" OutputFile="..\..\..\Binary\x64\Plugins\Plugin_VideoDX11DF.dll"
LinkIncremental="1" LinkIncremental="1"
SuppressStartupBanner="true" SuppressStartupBanner="true"

View File

@ -376,11 +376,12 @@ void Close()
{ {
// release all bound resources // release all bound resources
context->ClearState(); context->ClearState();
if (gfxstate) delete gfxstate;
SAFE_RELEASE(backbuf); SAFE_RELEASE(backbuf);
SAFE_RELEASE(context); if (gfxstate) delete gfxstate;
SAFE_RELEASE(swapchain); SAFE_RELEASE(swapchain);
context->Flush(); // immediately destroy device objects
SAFE_RELEASE(context);
ULONG references = device->Release(); ULONG references = device->Release();
if (references) if (references)
{ {
@ -403,12 +404,31 @@ unsigned int GetBackBufferHeight() { return yres; }
void Reset() void Reset()
{ {
DXGI_SWAP_CHAIN_DESC desc; // release all back buffer references
D3D::swapchain->ResizeBuffers(1, 0, 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0); SAFE_RELEASE(backbuf);
swapchain->GetDesc(&desc);
xres = desc.BufferDesc.Width; // resize swapchain buffers
yres = desc.BufferDesc.Height; RECT client;
// TODO: Check whether we need to do anything here GetClientRect(hWnd, &client);
xres = client.right - client.left;
yres = client.bottom - client.top;
D3D::swapchain->ResizeBuffers(1, xres, yres, DXGI_FORMAT_R8G8B8A8_UNORM, 0);
// recreate back buffer texture
ID3D11Texture2D* buf;
HRESULT hr = swapchain->GetBuffer(0, IID_ID3D11Texture2D, (void**)&buf);
if (FAILED(hr))
{
MessageBox(hWnd, _T("Failed to get swapchain buffer"), _T("Dolphin Direct3D 11 plugin"), MB_OK | MB_ICONERROR);
device->Release();
context->Release();
swapchain->Release();
return;
}
backbuf = new D3DTexture2D(buf, D3D11_BIND_RENDER_TARGET);
buf->Release();
SetDebugObjectName((ID3D11DeviceChild*)backbuf->GetTex(), "backbuffer texture");
SetDebugObjectName((ID3D11DeviceChild*)backbuf->GetRTV(), "backbuffer render target view");
} }
bool BeginFrame() bool BeginFrame()

View File

@ -45,7 +45,7 @@ void ReplaceTexture2D(ID3D11Texture2D* pTexture, const u8* buffer, unsigned int
if (usage == D3D11_USAGE_DYNAMIC || usage == D3D11_USAGE_STAGING) if (usage == D3D11_USAGE_DYNAMIC || usage == D3D11_USAGE_STAGING)
{ {
if (level != 0) PanicAlert("Dynamic textures don't support mipmaps, but given level is not 0 at %s %d\n", __FILE__, __LINE__); if (usage == D3D11_USAGE_DYNAMIC && level != 0) PanicAlert("Dynamic textures don't support mipmaps, but given level is not 0 at %s %d\n", __FILE__, __LINE__);
D3D11_MAPPED_SUBRESOURCE map; D3D11_MAPPED_SUBRESOURCE map;
D3D::context->Map(pTexture, 0, D3D11_MAP_WRITE_DISCARD, 0, &map); D3D::context->Map(pTexture, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
outptr = (u8*)map.pData; outptr = (u8*)map.pData;

View File

@ -174,6 +174,7 @@ int CD3DFont::Init()
PanicAlert("Failed to create font texture"); PanicAlert("Failed to create font texture");
return hr; return hr;
} }
D3D::SetDebugObjectName((ID3D11DeviceChild*)buftex, "texture of a CD3DFont object");
// lock the surface and write the alpha values for the set pixels // lock the surface and write the alpha values for the set pixels
D3D11_MAPPED_SUBRESOURCE texmap; D3D11_MAPPED_SUBRESOURCE texmap;
@ -205,12 +206,14 @@ int CD3DFont::Init()
// setup device objects for drawing // setup device objects for drawing
m_pshader = D3D::CompileAndCreatePixelShader(fontpixshader, sizeof(fontpixshader)); m_pshader = D3D::CompileAndCreatePixelShader(fontpixshader, sizeof(fontpixshader));
if (m_pshader == NULL) PanicAlert("Failed to create pixel shader, %s %d\n", __FILE__, __LINE__); if (m_pshader == NULL) PanicAlert("Failed to create pixel shader, %s %d\n", __FILE__, __LINE__);
D3D::SetDebugObjectName((ID3D11DeviceChild*)m_pshader, "pixel shader of a CD3DFont object");
D3DBlob* vsbytecode; D3DBlob* vsbytecode;
D3D::CompileVertexShader(fontvertshader, sizeof(fontvertshader), &vsbytecode); D3D::CompileVertexShader(fontvertshader, sizeof(fontvertshader), &vsbytecode);
if (vsbytecode == NULL) PanicAlert("Failed to compile vertex shader, %s %d\n", __FILE__, __LINE__); if (vsbytecode == NULL) PanicAlert("Failed to compile vertex shader, %s %d\n", __FILE__, __LINE__);
m_vshader = D3D::CreateVertexShaderFromByteCode(vsbytecode); m_vshader = D3D::CreateVertexShaderFromByteCode(vsbytecode);
if (m_vshader == NULL) PanicAlert("Failed to create vertex shader, %s %d\n", __FILE__, __LINE__); if (m_vshader == NULL) PanicAlert("Failed to create vertex shader, %s %d\n", __FILE__, __LINE__);
D3D::SetDebugObjectName((ID3D11DeviceChild*)m_vshader, "vertex shader of a CD3DFont object");
const D3D11_INPUT_ELEMENT_DESC desc[] = const D3D11_INPUT_ELEMENT_DESC desc[] =
{ {
@ -234,10 +237,12 @@ int CD3DFont::Init()
blenddesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA; blenddesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA;
blenddesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; blenddesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
D3D::device->CreateBlendState(&blenddesc, &m_blendstate); D3D::device->CreateBlendState(&blenddesc, &m_blendstate);
D3D::SetDebugObjectName((ID3D11DeviceChild*)m_blendstate, "blend state of a CD3DFont object");
// this might need to be changed when adding multisampling support // this might need to be changed when adding multisampling support
D3D11_RASTERIZER_DESC rastdesc = CD3D11_RASTERIZER_DESC(D3D11_FILL_SOLID, D3D11_CULL_NONE, false, 0, 0.f, 0.f, false, false, false, false); D3D11_RASTERIZER_DESC rastdesc = CD3D11_RASTERIZER_DESC(D3D11_FILL_SOLID, D3D11_CULL_NONE, false, 0, 0.f, 0.f, false, false, false, false);
D3D::device->CreateRasterizerState(&rastdesc, &m_raststate); D3D::device->CreateRasterizerState(&rastdesc, &m_raststate);
D3D::SetDebugObjectName((ID3D11DeviceChild*)m_raststate, "rasterizer state of a CD3DFont object");
D3D11_BUFFER_DESC vbdesc = CD3D11_BUFFER_DESC(MAX_NUM_VERTICES*sizeof(FONT2DVERTEX), D3D11_BIND_VERTEX_BUFFER, D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE); D3D11_BUFFER_DESC vbdesc = CD3D11_BUFFER_DESC(MAX_NUM_VERTICES*sizeof(FONT2DVERTEX), D3D11_BIND_VERTEX_BUFFER, D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE);
if (FAILED(hr = device->CreateBuffer(&vbdesc, NULL, &m_pVB))) if (FAILED(hr = device->CreateBuffer(&vbdesc, NULL, &m_pVB)))
@ -245,6 +250,7 @@ int CD3DFont::Init()
PanicAlert("Failed to create vertex buffer!\n"); PanicAlert("Failed to create vertex buffer!\n");
return hr; return hr;
} }
D3D::SetDebugObjectName((ID3D11DeviceChild*)m_pVB, "vertex buffer of a CD3DFont object");
return S_OK; return S_OK;
} }

View File

@ -166,15 +166,19 @@ void PixelShaderCache::Init()
{ {
// used when drawing clear quads // used when drawing clear quads
s_ClearProgram = D3D::CompileAndCreatePixelShader(clear_program_code, strlen(clear_program_code)); s_ClearProgram = D3D::CompileAndCreatePixelShader(clear_program_code, strlen(clear_program_code));
D3D::SetDebugObjectName((ID3D11DeviceChild*)s_ClearProgram, "clear pixel shader");
// used when copying/resolving the color buffer // used when copying/resolving the color buffer
s_ColorCopyProgram = D3D::CompileAndCreatePixelShader(color_copy_program_code, strlen(color_copy_program_code)); s_ColorCopyProgram = D3D::CompileAndCreatePixelShader(color_copy_program_code, strlen(color_copy_program_code));
D3D::SetDebugObjectName((ID3D11DeviceChild*)s_ClearProgram, "color copy pixel shader");
// used for color conversion // used for color conversion
s_ColorMatrixProgram = D3D::CompileAndCreatePixelShader(color_matrix_program_code, strlen(color_matrix_program_code)); s_ColorMatrixProgram = D3D::CompileAndCreatePixelShader(color_matrix_program_code, strlen(color_matrix_program_code));
D3D::SetDebugObjectName((ID3D11DeviceChild*)s_ClearProgram, "color matrix pixel shader");
// used for depth copy // used for depth copy
s_DepthMatrixProgram = D3D::CompileAndCreatePixelShader(depth_matrix_program, strlen(depth_matrix_program)); s_DepthMatrixProgram = D3D::CompileAndCreatePixelShader(depth_matrix_program, strlen(depth_matrix_program));
D3D::SetDebugObjectName((ID3D11DeviceChild*)s_ClearProgram, "depth matrix pixel shader");
Clear(); Clear();
@ -262,6 +266,8 @@ bool PixelShaderCache::InsertByteCode(const PIXELSHADERUID &uid, void* bytecode,
PanicAlert("Failed to create pixel shader at %s %d\n", __FILE__, __LINE__); PanicAlert("Failed to create pixel shader at %s %d\n", __FILE__, __LINE__);
return false; return false;
} }
// TODO: Somehow make the debug name a bit more specific
D3D::SetDebugObjectName((ID3D11DeviceChild*)shader, "a pixel shader of PixelShaderCache");
// make an entry in the table // make an entry in the table
PSCacheEntry newentry; PSCacheEntry newentry;
@ -274,4 +280,4 @@ bool PixelShaderCache::InsertByteCode(const PIXELSHADERUID &uid, void* bytecode,
SETSTAT(stats.numPixelShadersAlive, PixelShaders.size()); SETSTAT(stats.numPixelShadersAlive, PixelShaders.size());
return true; return true;
} }

View File

@ -70,6 +70,10 @@ static float yScale;
static u32 s_blendMode; static u32 s_blendMode;
static bool XFBWrited; static bool XFBWrited;
static bool s_bScreenshot = false;
static Common::CriticalSection s_criticalScreenshot;
static char s_sScreenshotName[1024];
ID3D11Buffer* access_efb_cbuf = NULL; ID3D11Buffer* access_efb_cbuf = NULL;
ID3D11DepthStencilState* cleardepthstates[2] = {NULL}; ID3D11DepthStencilState* cleardepthstates[2] = {NULL};
ID3D11RasterizerState* clearraststate = NULL; ID3D11RasterizerState* clearraststate = NULL;
@ -873,6 +877,11 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
D3D::drawShadedTexSubQuad(xfbSource->tex->GetSRV(), &sourceRc, xfbSource->texWidth, xfbSource->texHeight, &drawRc, PixelShaderCache::GetColorCopyProgram(),VertexShaderCache::GetSimpleVertexShader(), VertexShaderCache::GetSimpleInputLayout()); D3D::drawShadedTexSubQuad(xfbSource->tex->GetSRV(), &sourceRc, xfbSource->texWidth, xfbSource->texHeight, &drawRc, PixelShaderCache::GetColorCopyProgram(),VertexShaderCache::GetSimpleVertexShader(), VertexShaderCache::GetSimpleInputLayout());
} }
if (s_bScreenshot)
{
HRESULT hr = D3DX11SaveTextureToFileA(D3D::context, D3D::GetBackBuffer()->GetTex(), D3DX11_IFF_PNG, s_sScreenshotName);
s_bScreenshot = false;
}
vp = CD3D11_VIEWPORT(0.f, 0.f, s_backbuffer_width, s_backbuffer_height); vp = CD3D11_VIEWPORT(0.f, 0.f, s_backbuffer_width, s_backbuffer_height);
D3D::context->RSSetViewports(1, &vp); D3D::context->RSSetViewports(1, &vp);
@ -910,7 +919,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
UpdateActiveConfig(); UpdateActiveConfig();
WindowResized = false; WindowResized = false;
CheckForResize(); CheckForResize();
bool xfbchanged = false; bool xfbchanged = false;
if (s_XFB_width != fbWidth || s_XFB_height != fbHeight) if (s_XFB_width != fbWidth || s_XFB_height != fbHeight)
@ -931,9 +940,9 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
xScale = (float)(dst_rect.right - dst_rect.left) / (float)s_XFB_width; xScale = (float)(dst_rect.right - dst_rect.left) / (float)s_XFB_width;
yScale = (float)(dst_rect.bottom - dst_rect.top) / (float)s_XFB_height; yScale = (float)(dst_rect.bottom - dst_rect.top) / (float)s_XFB_height;
s_target_width = EFB_WIDTH * xScale; s_target_width = (int)(EFB_WIDTH * xScale);
s_target_height = EFB_HEIGHT * yScale; s_target_height = (int)(EFB_HEIGHT * yScale);
D3D::context->OMSetRenderTargets(1, &D3D::GetBackBuffer()->GetRTV(), NULL); D3D::context->OMSetRenderTargets(1, &D3D::GetBackBuffer()->GetRTV(), NULL);
FBManager.Destroy(); FBManager.Destroy();
@ -1096,5 +1105,9 @@ void Renderer::SetInterlacingMode()
// Save screenshot // Save screenshot
void Renderer::SetScreenshot(const char* filename) void Renderer::SetScreenshot(const char* filename)
{ {
PanicAlert("Renderer::SetScreenshot not implemented\n"); s_criticalScreenshot.Enter();
strcpy_s(s_sScreenshotName, filename);
s_bScreenshot = true;
s_criticalScreenshot.Leave();
} }

View File

@ -257,7 +257,13 @@ TextureCache::TCacheEntry* TextureCache::Load(unsigned int stage, u32 address, u
D3D11_USAGE usage = (TexLevels == 1) ? D3D11_USAGE_DYNAMIC : D3D11_USAGE_DEFAULT; D3D11_USAGE usage = (TexLevels == 1) ? D3D11_USAGE_DYNAMIC : D3D11_USAGE_DEFAULT;
if (!skip_texture_create) if (!skip_texture_create)
{ {
if (usage == D3D11_USAGE_DYNAMIC) entry.texture = D3DTexture2D::Create(width, height, D3D11_BIND_SHADER_RESOURCE, usage, d3d_fmt, TexLevels); // TODO: A little more verbosity in the debug names would be quite helpful..
if (usage == D3D11_USAGE_DYNAMIC)
{
entry.texture = D3DTexture2D::Create(width, height, D3D11_BIND_SHADER_RESOURCE, usage, d3d_fmt, TexLevels);
D3D::SetDebugObjectName((ID3D11DeviceChild*)entry.texture->GetTex(), "a (dynamic) texture of the TextureCache");
D3D::SetDebugObjectName((ID3D11DeviceChild*)entry.texture->GetSRV(), "shader resource view of a (dynamic) texture of the TextureCache");
}
else // need to use default textures else // need to use default textures
{ {
ID3D11Texture2D* pTexture = NULL; ID3D11Texture2D* pTexture = NULL;
@ -276,6 +282,8 @@ TextureCache::TCacheEntry* TextureCache::Load(unsigned int stage, u32 address, u
} }
// we only need the shader resource view // we only need the shader resource view
entry.texture = new D3DTexture2D(pTexture, D3D11_BIND_SHADER_RESOURCE); entry.texture = new D3DTexture2D(pTexture, D3D11_BIND_SHADER_RESOURCE);
D3D::SetDebugObjectName((ID3D11DeviceChild*)entry.texture->GetTex(), "a (static) texture of the TextureCache");
D3D::SetDebugObjectName((ID3D11DeviceChild*)entry.texture->GetSRV(), "shader resource view of a (static) texture of the TextureCache");
pTexture->Release(); pTexture->Release();
} }
if (entry.texture == NULL) PanicAlert("Failed to create texture at %s %d\n", __FILE__, __LINE__); if (entry.texture == NULL) PanicAlert("Failed to create texture at %s %d\n", __FILE__, __LINE__);

View File

@ -148,12 +148,16 @@ void VertexShaderCache::Init()
SimpleVertexShader = D3D::CreateVertexShaderFromByteCode(blob); SimpleVertexShader = D3D::CreateVertexShaderFromByteCode(blob);
if (SimpleLayout == NULL || SimpleVertexShader == NULL) PanicAlert("Failed to create simple vertex shader or input layout at %s %d\n", __FILE__, __LINE__); if (SimpleLayout == NULL || SimpleVertexShader == NULL) PanicAlert("Failed to create simple vertex shader or input layout at %s %d\n", __FILE__, __LINE__);
blob->Release(); blob->Release();
D3D::SetDebugObjectName((ID3D11DeviceChild*)SimpleVertexShader, "simple vertex shader");
D3D::SetDebugObjectName((ID3D11DeviceChild*)SimpleLayout, "simple input layout");
D3D::CompileVertexShader(clear_shader_code, (int)strlen(clear_shader_code), &blob); D3D::CompileVertexShader(clear_shader_code, (int)strlen(clear_shader_code), &blob);
D3D::device->CreateInputLayout(clearelems, 2, blob->Data(), blob->Size(), &ClearLayout); D3D::device->CreateInputLayout(clearelems, 2, blob->Data(), blob->Size(), &ClearLayout);
ClearVertexShader = D3D::CreateVertexShaderFromByteCode(blob); ClearVertexShader = D3D::CreateVertexShaderFromByteCode(blob);
if (ClearLayout == NULL || ClearVertexShader == NULL) PanicAlert("Failed to create clear vertex shader or input layout at %s %d\n", __FILE__, __LINE__); if (ClearLayout == NULL || ClearVertexShader == NULL) PanicAlert("Failed to create clear vertex shader or input layout at %s %d\n", __FILE__, __LINE__);
blob->Release(); blob->Release();
D3D::SetDebugObjectName((ID3D11DeviceChild*)ClearVertexShader, "clear vertex shader");
D3D::SetDebugObjectName((ID3D11DeviceChild*)ClearLayout, "clear input layout");
Clear(); Clear();
@ -249,6 +253,8 @@ bool VertexShaderCache::InsertByteCode(const VERTEXSHADERUID &uid, D3DBlob* bcod
PanicAlert("Failed to create vertex shader from %p size %d at %s %d\n", bcodeblob->Data(), bcodeblob->Size(), __FILE__, __LINE__); PanicAlert("Failed to create vertex shader from %p size %d at %s %d\n", bcodeblob->Data(), bcodeblob->Size(), __FILE__, __LINE__);
return false; return false;
} }
// TODO: Somehow make the debug name a bit more specific
D3D::SetDebugObjectName((ID3D11DeviceChild*)shader, "a vertex shader of VertexShaderCache");
// Make an entry in the table // Make an entry in the table
VSCacheEntry entry; VSCacheEntry entry;

View File

@ -53,7 +53,7 @@ private:
VSCacheEntry() : shader(NULL), bytecode(NULL), frameCount(0) {} VSCacheEntry() : shader(NULL), bytecode(NULL), frameCount(0) {}
void SetByteCode(D3DBlob* blob) void SetByteCode(D3DBlob* blob)
{ {
if (bytecode) bytecode->Release(); SAFE_RELEASE(bytecode);
bytecode = blob; bytecode = blob;
blob->AddRef(); blob->AddRef();
} }
@ -63,7 +63,6 @@ private:
SAFE_RELEASE(bytecode); SAFE_RELEASE(bytecode);
} }
}; };
typedef std::map<VERTEXSHADERUID, VSCacheEntry> VSCache; typedef std::map<VERTEXSHADERUID, VSCacheEntry> VSCache;
static VSCache vshaders; static VSCache vshaders;

View File

@ -385,6 +385,7 @@ HRESULT ScreenShot(const char* filename)
void Video_Screenshot(const char* _szFilename) void Video_Screenshot(const char* _szFilename)
{ {
Renderer::SetScreenshot(_szFilename);
} }
static struct static struct