diff --git a/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp b/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp index 65d2a18b5f..57fd07d9d7 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp @@ -178,7 +178,8 @@ void EmuGfxState::ApplyState() { unsigned int size = ((sizeof(float)*952)&(~0xffff))+0x10000; // must be a multiple of 16 D3D11_BUFFER_DESC cbdesc = CD3D11_BUFFER_DESC(size, D3D11_BIND_CONSTANT_BUFFER, D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE); - device->CreateBuffer(&cbdesc, NULL, &vscbuf); + hr = device->CreateBuffer(&cbdesc, NULL, &vscbuf); + CHECK(hr==S_OK, "Create vertex shader constant buffer (size=%u)", size); SetDebugObjectName((ID3D11DeviceChild*)vscbuf, "a vertex shader constant buffer of EmuGfxState"); } if (vscbufchanged) @@ -196,6 +197,7 @@ void EmuGfxState::ApplyState() unsigned int size = ((sizeof(float)*116)&(~0xffff))+0x10000; // must be a multiple of 16 D3D11_BUFFER_DESC cbdesc = CD3D11_BUFFER_DESC(size, D3D11_BIND_CONSTANT_BUFFER, D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE); device->CreateBuffer(&cbdesc, NULL, &pscbuf); + CHECK(hr==S_OK, "Create pixel shader constant buffer (size=%u)", size); SetDebugObjectName((ID3D11DeviceChild*)pscbuf, "a pixel shader constant buffer of EmuGfxState"); } if (pscbufchanged) @@ -363,6 +365,7 @@ HRESULT Create(HWND wnd) } backbuf = new D3DTexture2D(buf, D3D11_BIND_RENDER_TARGET); buf->Release(); + CHECK(backbuf!=NULL, "Create back buffer texture"); SetDebugObjectName((ID3D11DeviceChild*)backbuf->GetTex(), "backbuffer texture"); SetDebugObjectName((ID3D11DeviceChild*)backbuf->GetRTV(), "backbuffer render target view"); @@ -427,6 +430,7 @@ void Reset() } backbuf = new D3DTexture2D(buf, D3D11_BIND_RENDER_TARGET); buf->Release(); + CHECK(backbuf!=NULL, "Create back buffer texture"); SetDebugObjectName((ID3D11DeviceChild*)backbuf->GetTex(), "backbuffer texture"); SetDebugObjectName((ID3D11DeviceChild*)backbuf->GetRTV(), "backbuffer render target view"); } diff --git a/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp b/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp index b655e12f9d..0517e1bcdd 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp @@ -236,18 +236,20 @@ int CD3DFont::Init() blenddesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC_ALPHA; blenddesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA; blenddesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; - D3D::device->CreateBlendState(&blenddesc, &m_blendstate); + hr = D3D::device->CreateBlendState(&blenddesc, &m_blendstate); + CHECK(hr==S_OK, "Create font blend state"); D3D::SetDebugObjectName((ID3D11DeviceChild*)m_blendstate, "blend state of a CD3DFont object"); // 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); - D3D::device->CreateRasterizerState(&rastdesc, &m_raststate); + hr = D3D::device->CreateRasterizerState(&rastdesc, &m_raststate); + CHECK(hr==S_OK, "Create font rasterizer state"); 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); if (FAILED(hr = device->CreateBuffer(&vbdesc, NULL, &m_pVB))) { - PanicAlert("Failed to create vertex buffer!\n"); + PanicAlert("Failed to create font vertex buffer at %s, line %d\n", __FILE__, __LINE__); return hr; } D3D::SetDebugObjectName((ID3D11DeviceChild*)m_pVB, "vertex buffer of a CD3DFont object"); @@ -420,12 +422,15 @@ void InitUtils() else SetDebugObjectName((ID3D11DeviceChild*)stqsamplerstate, "sampler state of drawShadedTexQuad"); stqvb = CreateQuadVertexBuffer(4*sizeof(STQVertex), NULL); + CHECK(stqvb!=NULL, "Create vertex buffer of drawShadedTexQuad"); SetDebugObjectName((ID3D11DeviceChild*)stqvb, "vertex buffer of drawShadedTexQuad"); stsqvb = CreateQuadVertexBuffer(4*sizeof(STSQVertex), NULL); + CHECK(stsqvb!=NULL, "Create vertex buffer of drawShadedTexSubQuad"); SetDebugObjectName((ID3D11DeviceChild*)stsqvb, "vertex buffer of drawShadedTexSubQuad"); clearvb = CreateQuadVertexBuffer(4*sizeof(ClearVertex), NULL); + CHECK(clearvb!=NULL, "Create vertex buffer of drawClearQuad"); SetDebugObjectName((ID3D11DeviceChild*)clearvb, "vertex buffer of drawClearQuad"); samDesc = CD3D11_SAMPLER_DESC(D3D11_FILTER_MIN_MAG_MIP_POINT, D3D11_TEXTURE_ADDRESS_CLAMP, D3D11_TEXTURE_ADDRESS_CLAMP, D3D11_TEXTURE_ADDRESS_CLAMP, 0.f, 16, D3D11_COMPARISON_ALWAYS, border, -D3D11_FLOAT32_MAX, D3D11_FLOAT32_MAX); diff --git a/Source/Plugins/Plugin_VideoDX11/Src/FBManager.cpp b/Source/Plugins/Plugin_VideoDX11/Src/FBManager.cpp index fc8308ece4..cdc0be2d79 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/FBManager.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/FBManager.cpp @@ -84,7 +84,8 @@ void FramebufferManager::Create() // sampler state for FramebufferManager::copyToVirtualXFB float border[4] = {0.f, 0.f, 0.f, 0.f}; D3D11_SAMPLER_DESC samplerdesc = CD3D11_SAMPLER_DESC(D3D11_FILTER_MIN_MAG_MIP_LINEAR, D3D11_TEXTURE_ADDRESS_CLAMP, D3D11_TEXTURE_ADDRESS_CLAMP, D3D11_TEXTURE_ADDRESS_CLAMP, 0.f, 1, D3D11_COMPARISON_ALWAYS, border, -D3D11_FLOAT32_MAX, D3D11_FLOAT32_MAX); - D3D::device->CreateSamplerState(&samplerdesc, ©toVirtualXFBsampler); + hr = D3D::device->CreateSamplerState(&samplerdesc, ©toVirtualXFBsampler); + CHECK(hr==S_OK, "Create sampler state for FramebufferManager::copyToVirtualXFB"); D3D::SetDebugObjectName((ID3D11DeviceChild*)copytoVirtualXFBsampler, "sampler state used for FramebufferManager::copyToVirtualXFB"); } diff --git a/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp index 8d3752b80f..426a409009 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp @@ -166,18 +166,22 @@ void PixelShaderCache::Init() { // used when drawing clear quads s_ClearProgram = D3D::CompileAndCreatePixelShader(clear_program_code, strlen(clear_program_code)); + CHECK(s_ClearProgram!=NULL, "Create clear pixel shader"); D3D::SetDebugObjectName((ID3D11DeviceChild*)s_ClearProgram, "clear pixel shader"); // used when copying/resolving the color buffer s_ColorCopyProgram = D3D::CompileAndCreatePixelShader(color_copy_program_code, strlen(color_copy_program_code)); + CHECK(s_ColorCopyProgram!=NULL, "Create color copy pixel shader"); D3D::SetDebugObjectName((ID3D11DeviceChild*)s_ClearProgram, "color copy pixel shader"); // used for color conversion s_ColorMatrixProgram = D3D::CompileAndCreatePixelShader(color_matrix_program_code, strlen(color_matrix_program_code)); + CHECK(s_ColorMatrixProgram!=NULL, "Create color matrix pixel shader"); D3D::SetDebugObjectName((ID3D11DeviceChild*)s_ClearProgram, "color matrix pixel shader"); // used for depth copy s_DepthMatrixProgram = D3D::CompileAndCreatePixelShader(depth_matrix_program, strlen(depth_matrix_program)); + CHECK(s_DepthMatrixProgram!=NULL, "Create depth matrix pixel shader"); D3D::SetDebugObjectName((ID3D11DeviceChild*)s_ClearProgram, "depth matrix pixel shader"); Clear(); diff --git a/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp index 6b65824c81..e0f94ade4d 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp @@ -228,6 +228,8 @@ static const D3D11_TEXTURE_ADDRESS_MODE d3dClamps[4] = void SetupDeviceObjects() { + HRESULT hr; + D3D::font.Init(); VertexLoaderManager::Init(); FBManager.Create(); @@ -240,7 +242,9 @@ void SetupDeviceObjects() D3D11_BUFFER_DESC cbdesc = CD3D11_BUFFER_DESC(20*sizeof(float), D3D11_BIND_CONSTANT_BUFFER, D3D11_USAGE_DEFAULT); D3D11_SUBRESOURCE_DATA data; data.pSysMem = colmat; - D3D::device->CreateBuffer(&cbdesc, &data, &access_efb_cbuf); + hr = D3D::device->CreateBuffer(&cbdesc, &data, &access_efb_cbuf); + CHECK(hr==S_OK, "Create constant buffer for Renderer::AccessEFB"); + D3D::SetDebugObjectName((ID3D11DeviceChild*)access_efb_cbuf, "constant buffer for Renderer::AccessEFB"); D3D11_DEPTH_STENCIL_DESC ddesc; ddesc.DepthEnable = FALSE; @@ -249,16 +253,19 @@ void SetupDeviceObjects() ddesc.StencilEnable = FALSE; ddesc.StencilReadMask = D3D11_DEFAULT_STENCIL_READ_MASK; ddesc.StencilWriteMask = D3D11_DEFAULT_STENCIL_WRITE_MASK; - D3D::device->CreateDepthStencilState(&ddesc, &cleardepthstates[0]); + hr = D3D::device->CreateDepthStencilState(&ddesc, &cleardepthstates[0]); + CHECK(hr==S_OK, "Create depth state for Renderer::ClearScreen"); ddesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL; ddesc.DepthEnable = TRUE; - D3D::device->CreateDepthStencilState(&ddesc, &cleardepthstates[1]); + hr = D3D::device->CreateDepthStencilState(&ddesc, &cleardepthstates[1]); + CHECK(hr==S_OK, "Create depth state for Renderer::ClearScreen"); D3D::SetDebugObjectName((ID3D11DeviceChild*)cleardepthstates[0], "depth state for Renderer::ClearScreen (depth buffer disabled)"); D3D::SetDebugObjectName((ID3D11DeviceChild*)cleardepthstates[1], "depth state for Renderer::ClearScreen (depth buffer enabled)"); // TODO: once multisampling gets implemented, this might need to be changed D3D11_RASTERIZER_DESC rdesc = CD3D11_RASTERIZER_DESC(D3D11_FILL_SOLID, D3D11_CULL_NONE, false, 0, 0.f, 0.f, false, true, false, false); - D3D::device->CreateRasterizerState(&rdesc, &clearraststate); + hr = D3D::device->CreateRasterizerState(&rdesc, &clearraststate); + CHECK(hr==S_OK, "Create rasterizer state for Renderer::ClearScreen"); D3D::SetDebugObjectName((ID3D11DeviceChild*)clearraststate, "rasterizer state for Renderer::ClearScreen"); D3D11_BLEND_DESC blenddesc; @@ -272,7 +279,8 @@ void SetupDeviceObjects() blenddesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; blenddesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO; blenddesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; - D3D::device->CreateBlendState(&blenddesc, &resetblendstate); + hr = D3D::device->CreateBlendState(&blenddesc, &resetblendstate); + CHECK(hr==S_OK, "Create blend state for Renderer::ResetAPIState"); D3D::SetDebugObjectName((ID3D11DeviceChild*)resetblendstate, "blend state for Renderer::ResetAPIState"); // TODO: For some reason this overwrites existing resource private data... @@ -282,12 +290,14 @@ void SetupDeviceObjects() ddesc.StencilEnable = FALSE; ddesc.StencilReadMask = D3D11_DEFAULT_STENCIL_READ_MASK; ddesc.StencilWriteMask = D3D11_DEFAULT_STENCIL_WRITE_MASK; - D3D::device->CreateDepthStencilState(&ddesc, &resetdepthstate); + hr = D3D::device->CreateDepthStencilState(&ddesc, &resetdepthstate); + CHECK(hr==S_OK, "Create depth state for Renderer::ResetAPIState"); D3D::SetDebugObjectName((ID3D11DeviceChild*)resetdepthstate, "depth stencil state for Renderer::ResetAPIState"); // this might need to be changed once multisampling support gets added 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, &resetraststate); + hr = D3D::device->CreateRasterizerState(&rastdesc, &resetraststate); + CHECK(hr==S_OK, "Create rasterizer state for Renderer::ClearScreen"); D3D::SetDebugObjectName((ID3D11DeviceChild*)resetraststate, "rasterizer state for Renderer::ResetAPIState"); } diff --git a/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.cpp index 13fc867a32..d0848a4c57 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/TextureCache.cpp @@ -67,6 +67,8 @@ void TextureCache::TCacheEntry::Destroy(bool shutdown) void TextureCache::Init() { + HRESULT hr; + temp = (u8*)AllocateMemoryPages(TEMP_SIZE); TexDecoder_SetTexFmtOverlayOptions(g_ActiveConfig.bTexFmtOverlayEnable, g_ActiveConfig.bTexFmtOverlayCenter); HiresTextures::Init(globals->unique_id); @@ -82,7 +84,8 @@ void TextureCache::Init() blenddesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; blenddesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO; blenddesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; - D3D::device->CreateBlendState(&blenddesc, &efbcopyblendstate); + hr = D3D::device->CreateBlendState(&blenddesc, &efbcopyblendstate); + CHECK(hr==S_OK, "Create blend state for TextureCache::CopyRenderTargetToTexture"); D3D::SetDebugObjectName((ID3D11DeviceChild*)efbcopyblendstate, "blend state used in TextureCache::CopyRenderTargetToTexture"); D3D11_DEPTH_STENCIL_DESC depthdesc; @@ -92,7 +95,8 @@ void TextureCache::Init() depthdesc.StencilEnable = FALSE; depthdesc.StencilReadMask = D3D11_DEFAULT_STENCIL_READ_MASK; depthdesc.StencilWriteMask = D3D11_DEFAULT_STENCIL_WRITE_MASK; - D3D::device->CreateDepthStencilState(&depthdesc, &efbcopydepthstate); + hr = D3D::device->CreateDepthStencilState(&depthdesc, &efbcopydepthstate); + CHECK(hr==S_OK, "Create depth state for TextureCache::CopyRenderTargetToTexture"); D3D::SetDebugObjectName((ID3D11DeviceChild*)efbcopydepthstate, "depth stencil state used in TextureCache::CopyRenderTargetToTexture"); D3D11_RASTERIZER_DESC rastdesc; @@ -106,7 +110,8 @@ void TextureCache::Init() rastdesc.ScissorEnable = false; rastdesc.MultisampleEnable = false; rastdesc.AntialiasedLineEnable = false; - D3D::device->CreateRasterizerState(&rastdesc, &efbcopyraststate); + hr = D3D::device->CreateRasterizerState(&rastdesc, &efbcopyraststate); + CHECK(hr==S_OK, "Create rasterizer state for TextureCache::CopyRenderTargetToTexture"); D3D::SetDebugObjectName((ID3D11DeviceChild*)efbcopyraststate, "rasterizer state used in TextureCache::CopyRenderTargetToTexture"); } @@ -289,6 +294,7 @@ TextureCache::TCacheEntry* TextureCache::Load(unsigned int stage, u32 address, u if (usage == D3D11_USAGE_DYNAMIC) { entry.texture = D3DTexture2D::Create(width, height, D3D11_BIND_SHADER_RESOURCE, usage, d3d_fmt, TexLevels); + CHECK(entry.texture!=NULL, "Create dynamic texture of the TextureCache"); 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"); } @@ -305,6 +311,7 @@ TextureCache::TCacheEntry* TextureCache::Load(unsigned int stage, u32 address, u return NULL; } entry.texture = new D3DTexture2D(pTexture, D3D11_BIND_SHADER_RESOURCE); + CHECK(entry.texture!=NULL, "Create dynamic texture of the TextureCache"); 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(); @@ -543,7 +550,9 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo D3D11_BUFFER_DESC cbdesc = CD3D11_BUFFER_DESC(20*sizeof(float), D3D11_BIND_CONSTANT_BUFFER, D3D11_USAGE_DEFAULT); D3D11_SUBRESOURCE_DATA data; data.pSysMem = colmat; - D3D::device->CreateBuffer(&cbdesc, &data, &efbcopycbuf[cbufid]); + HRESULT hr = D3D::device->CreateBuffer(&cbdesc, &data, &efbcopycbuf[cbufid]); + CHECK(hr==S_OK, "Create efb copy constant buffer %d", cbufid); + D3D::SetDebugObjectName((ID3D11DeviceChild*)efbcopycbuf[cbufid], "a constant buffer used in TextureCache::CopyRenderTargetToTexture"); } D3D::context->PSSetConstantBuffers(0, 1, &efbcopycbuf[cbufid]); diff --git a/Source/Plugins/Plugin_VideoDX11/Src/main.cpp b/Source/Plugins/Plugin_VideoDX11/Src/main.cpp index 8c9a487c84..9c934ae1e2 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/main.cpp @@ -105,20 +105,14 @@ bool IsD3D11() // This is used for the functions right below here which use wxwidgets #if defined(HAVE_WX) && HAVE_WX -#ifdef _WIN32 - WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst); -#endif +WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst); wxWindow* GetParentedWxWindow(HWND Parent) { -#ifdef _WIN32 wxSetInstance((HINSTANCE)g_hInstance); -#endif wxWindow* win = new wxWindow(); -#ifdef _WIN32 win->SetHWND((WXHWND)Parent); win->AdoptAttributesFromHWND(); -#endif return win; } #endif @@ -183,7 +177,7 @@ void UpdateFPSDisplay(const char* text) SetWindowTextA(EmuWindow::GetWnd(), temp); } -void GetDllInfo (PLUGIN_INFO* _PluginInfo) +void GetDllInfo(PLUGIN_INFO* _PluginInfo) { _PluginInfo->Version = 0x0100; _PluginInfo->Type = PLUGIN_TYPE_VIDEO; diff --git a/Source/Plugins/Plugin_VideoDX9/Src/main.cpp b/Source/Plugins/Plugin_VideoDX9/Src/main.cpp index 9b3037dad1..d0e8154977 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/main.cpp @@ -93,20 +93,14 @@ bool IsD3D() // This is used for the functions right below here which use wxwidgets #if defined(HAVE_WX) && HAVE_WX -#ifdef _WIN32 - WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst); -#endif +WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst); wxWindow* GetParentedWxWindow(HWND Parent) { -#ifdef _WIN32 wxSetInstance((HINSTANCE)g_hInstance); -#endif wxWindow *win = new wxWindow(); -#ifdef _WIN32 win->SetHWND((WXHWND)Parent); win->AdoptAttributesFromHWND(); -#endif return win; } #endif @@ -219,20 +213,16 @@ void DllConfig(HWND _hParent) m_ConfigFrame = new GFXConfigDialogDX(frame); // Prevent user to show more than 1 config window at same time -#ifdef _WIN32 frame->Disable(); m_ConfigFrame->CreateGUIControls(); m_ConfigFrame->ShowModal(); frame->Enable(); -#else m_ConfigFrame->CreateGUIControls(); m_ConfigFrame->ShowModal(); #endif -#ifdef _WIN32 frame->SetFocus(); frame->SetHWND(NULL); -#endif m_ConfigFrame->Destroy(); m_ConfigFrame = NULL;