diff --git a/Source/DSPSpy/build.sh b/Source/DSPSpy/build.sh index bf71edccf5..fa6165d6c8 100644 --- a/Source/DSPSpy/build.sh +++ b/Source/DSPSpy/build.sh @@ -1,6 +1,6 @@ ../../Binary/x64/DSPTool.exe -h dsp_code tests/mul_test.ds mkdir emu -cp ../Core/DSPCore/Src/*.cpp emu -cp ../Core/DSPCore/Src/*.h emu +cp ../Core/Core/Src/DSP/Src/*.cpp emu +cp ../Core/Core/Src/DSP/Src/*.h emu make diff --git a/Source/Dolphin.sln b/Source/Dolphin.sln index 610ed7b47e..d87057309b 100644 --- a/Source/Dolphin.sln +++ b/Source/Dolphin.sln @@ -8,7 +8,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Core", "Core\Core\Core.vcpr {FBAFB369-07EB-4460-9CAD-08BE5789DAB6} = {FBAFB369-07EB-4460-9CAD-08BE5789DAB6} {3E03C179-8251-46E4-81F4-466F114BAC63} = {3E03C179-8251-46E4-81F4-466F114BAC63} {823DDC98-42D5-4A38-88CF-9DC06C788AE4} = {823DDC98-42D5-4A38-88CF-9DC06C788AE4} - {838A89A3-3AA0-4A45-ACBE-3D1E0980C2ED} = {838A89A3-3AA0-4A45-ACBE-3D1E0980C2ED} {29C2ABC1-ADA5-42CD-A5FC-96022D52A510} = {29C2ABC1-ADA5-42CD-A5FC-96022D52A510} {B807E8DB-4241-4754-BC2A-2F435BCA881A} = {B807E8DB-4241-4754-BC2A-2F435BCA881A} {C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9} @@ -85,7 +84,6 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Debugger", "Core\DebuggerWX\DebuggerWX.vcproj", "{4D3CD4C5-412B-4B49-9B1B-A68A2A129C77}" ProjectSection(ProjectDependencies) = postProject {F81AE75C-3D17-4D8C-A201-82FA5351C123} = {F81AE75C-3D17-4D8C-A201-82FA5351C123} - {838A89A3-3AA0-4A45-ACBE-3D1E0980C2ED} = {838A89A3-3AA0-4A45-ACBE-3D1E0980C2ED} {29C2ABC1-ADA5-42CD-A5FC-96022D52A510} = {29C2ABC1-ADA5-42CD-A5FC-96022D52A510} {F0B874CB-4476-4199-9315-8343D05AE684} = {F0B874CB-4476-4199-9315-8343D05AE684} {B807E8DB-4241-4754-BC2A-2F435BCA881A} = {B807E8DB-4241-4754-BC2A-2F435BCA881A} @@ -118,7 +116,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AudioCommon", "Core\AudioCo EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DSPTool", "DSPTool\DSPTool.vcproj", "{1970D175-3DE8-4738-942A-4D98D1CDBF64}" ProjectSection(ProjectDependencies) = postProject - {838A89A3-3AA0-4A45-ACBE-3D1E0980C2ED} = {838A89A3-3AA0-4A45-ACBE-3D1E0980C2ED} + {F0B874CB-4476-4199-9315-8343D05AE684} = {F0B874CB-4476-4199-9315-8343D05AE684} {B807E8DB-4241-4754-BC2A-2F435BCA881A} = {B807E8DB-4241-4754-BC2A-2F435BCA881A} {C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9} EndProjectSection @@ -142,7 +140,6 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTests", "UnitTests\UnitTests.vcproj", "{40C636FA-B5BF-4D67-ABC8-376B524A7551}" ProjectSection(ProjectDependencies) = postProject {11F55366-12EC-4C44-A8CB-1D4E315D61ED} = {11F55366-12EC-4C44-A8CB-1D4E315D61ED} - {838A89A3-3AA0-4A45-ACBE-3D1E0980C2ED} = {838A89A3-3AA0-4A45-ACBE-3D1E0980C2ED} {1C8436C9-DBAF-42BE-83BC-CF3EC9175ABE} = {1C8436C9-DBAF-42BE-83BC-CF3EC9175ABE} {F0B874CB-4476-4199-9315-8343D05AE684} = {F0B874CB-4476-4199-9315-8343D05AE684} {B807E8DB-4241-4754-BC2A-2F435BCA881A} = {B807E8DB-4241-4754-BC2A-2F435BCA881A} @@ -388,18 +385,6 @@ Global {FBAFB369-07EB-4460-9CAD-08BE5789DAB6}.Release|Win32.Build.0 = Release|Win32 {FBAFB369-07EB-4460-9CAD-08BE5789DAB6}.Release|x64.ActiveCfg = Release|x64 {FBAFB369-07EB-4460-9CAD-08BE5789DAB6}.Release|x64.Build.0 = Release|x64 - {838A89A3-3AA0-4A45-ACBE-3D1E0980C2ED}.Debug|Win32.ActiveCfg = Debug|Win32 - {838A89A3-3AA0-4A45-ACBE-3D1E0980C2ED}.Debug|Win32.Build.0 = Debug|Win32 - {838A89A3-3AA0-4A45-ACBE-3D1E0980C2ED}.Debug|x64.ActiveCfg = Debug|x64 - {838A89A3-3AA0-4A45-ACBE-3D1E0980C2ED}.Debug|x64.Build.0 = Debug|x64 - {838A89A3-3AA0-4A45-ACBE-3D1E0980C2ED}.DebugFast|Win32.ActiveCfg = DebugFast|Win32 - {838A89A3-3AA0-4A45-ACBE-3D1E0980C2ED}.DebugFast|Win32.Build.0 = DebugFast|Win32 - {838A89A3-3AA0-4A45-ACBE-3D1E0980C2ED}.DebugFast|x64.ActiveCfg = DebugFast|x64 - {838A89A3-3AA0-4A45-ACBE-3D1E0980C2ED}.DebugFast|x64.Build.0 = DebugFast|x64 - {838A89A3-3AA0-4A45-ACBE-3D1E0980C2ED}.Release|Win32.ActiveCfg = Release|Win32 - {838A89A3-3AA0-4A45-ACBE-3D1E0980C2ED}.Release|Win32.Build.0 = Release|Win32 - {838A89A3-3AA0-4A45-ACBE-3D1E0980C2ED}.Release|x64.ActiveCfg = Release|x64 - {838A89A3-3AA0-4A45-ACBE-3D1E0980C2ED}.Release|x64.Build.0 = Release|x64 {1970D175-3DE8-4738-942A-4D98D1CDBF64}.Debug|Win32.ActiveCfg = Debug|Win32 {1970D175-3DE8-4738-942A-4D98D1CDBF64}.Debug|Win32.Build.0 = Debug|Win32 {1970D175-3DE8-4738-942A-4D98D1CDBF64}.Debug|x64.ActiveCfg = Debug|x64 @@ -597,9 +582,9 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - AMDCaPersistentConfig = Release|x64 - AMDCaPersistentStartup = Dolphin AMDCaProjectFile = G:\Dolphin\Source\CodeAnalyst\Dolphin.caw + AMDCaPersistentStartup = Dolphin + AMDCaPersistentConfig = Release|x64 EndGlobalSection GlobalSection(DPCodeReviewSolutionGUID) = preSolution DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} diff --git a/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp b/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp index c229802987..36a07736ee 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.cpp @@ -22,6 +22,9 @@ #include "D3DTexture.h" #include "GfxState.h" +namespace DX11 +{ + HINSTANCE hD3DXDll = NULL; D3DX11COMPILEFROMMEMORYTYPE PD3DX11CompileFromMemory = NULL; D3DX11FILTERTEXTURETYPE PD3DX11FilterTexture = NULL; @@ -468,4 +471,6 @@ void Present() swapchain->Present((UINT)g_ActiveConfig.bVSync, 0); } -} // namespace +} // namespace D3D + +} // namespace DX11 \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.h b/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.h index 80d0c0ae1f..1ef24fba23 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.h +++ b/Source/Plugins/Plugin_VideoDX11/Src/D3DBase.h @@ -21,12 +21,16 @@ #include "Common.h" #include +namespace DX11 +{ + #define SAFE_RELEASE(x) { if (x) (x)->Release(); (x) = NULL; } #define SAFE_DELETE(x) { delete (x); (x) = NULL; } #define SAFE_DELETE_ARRAY(x) { delete[] (x); (x) = NULL; } #define CHECK(cond, Message, ...) if (!(cond)) { PanicAlert(__FUNCTION__ "Failed in %s at line %d: " Message, __FILE__, __LINE__, __VA_ARGS__); } class D3DTexture2D; + namespace D3D { @@ -100,3 +104,5 @@ typedef HRESULT (WINAPI* CREATEDXGIFACTORY)(REFIID, void**); extern CREATEDXGIFACTORY PCreateDXGIFactory; typedef HRESULT (WINAPI* D3D11CREATEDEVICE)(IDXGIAdapter*, D3D_DRIVER_TYPE, HMODULE, UINT, CONST D3D_FEATURE_LEVEL*, UINT, UINT, ID3D11Device**, D3D_FEATURE_LEVEL*, ID3D11DeviceContext**); extern D3D11CREATEDEVICE PD3D11CreateDevice; + +} // namespace DX11 \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX11/Src/D3DBlob.cpp b/Source/Plugins/Plugin_VideoDX11/Src/D3DBlob.cpp index e5a069b0d4..6700de5540 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/D3DBlob.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/D3DBlob.cpp @@ -18,6 +18,9 @@ #include #include "D3DBlob.h" +namespace DX11 +{ + D3DBlob::D3DBlob(unsigned int blob_size, const u8* init_data) : ref(1), size(blob_size), blob(NULL) { data = new u8[blob_size]; @@ -62,3 +65,5 @@ u8* D3DBlob::Data() { return data; } + +} // namespace DX11 \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX11/Src/D3DBlob.h b/Source/Plugins/Plugin_VideoDX11/Src/D3DBlob.h index 0362f45ef6..b5c80662b8 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/D3DBlob.h +++ b/Source/Plugins/Plugin_VideoDX11/Src/D3DBlob.h @@ -21,6 +21,9 @@ struct ID3D10Blob; +namespace DX11 +{ + // use this class instead ID3D10Blob or ID3D11Blob whenever possible class D3DBlob { @@ -46,3 +49,5 @@ private: u8* data; ID3D10Blob* blob; }; + +} // namespace \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX11/Src/D3DShader.cpp b/Source/Plugins/Plugin_VideoDX11/Src/D3DShader.cpp index e7bcf05260..8d8ded362b 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/D3DShader.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/D3DShader.cpp @@ -22,6 +22,9 @@ #include "D3DBase.h" #include "D3DShader.h" +namespace DX11 +{ + namespace D3D { @@ -149,3 +152,5 @@ ID3D11PixelShader* CompileAndCreatePixelShader(const char* code, unsigned int le } } // namespace + +} // namespace DX11 \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX11/Src/D3DShader.h b/Source/Plugins/Plugin_VideoDX11/Src/D3DShader.h index c88add9b07..49407dc767 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/D3DShader.h +++ b/Source/Plugins/Plugin_VideoDX11/Src/D3DShader.h @@ -22,6 +22,9 @@ struct ID3D11PixelShader; struct ID3D11VertexShader; +namespace DX11 +{ + namespace D3D { ID3D11VertexShader* CreateVertexShaderFromByteCode(const void* bytecode, unsigned int len); @@ -39,4 +42,6 @@ namespace D3D inline ID3D11PixelShader* CreatePixelShaderFromByteCode(D3DBlob* bytecode) { return CreatePixelShaderFromByteCode(bytecode->Data(), bytecode->Size()); } inline ID3D11VertexShader* CompileAndCreateVertexShader(D3DBlob* code) { return CompileAndCreateVertexShader((const char*)code->Data(), code->Size()); } inline ID3D11PixelShader* CompileAndCreatePixelShader(D3DBlob* code) { return CompileAndCreatePixelShader((const char*)code->Data(), code->Size()); } -} \ No newline at end of file +} + +} // namespace DX11 \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX11/Src/D3DTexture.cpp b/Source/Plugins/Plugin_VideoDX11/Src/D3DTexture.cpp index 95f68856c6..25e8d223a3 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/D3DTexture.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/D3DTexture.cpp @@ -18,6 +18,9 @@ #include "D3DBase.h" #include "D3DTexture.h" +namespace DX11 +{ + namespace D3D { @@ -113,3 +116,5 @@ D3DTexture2D::~D3DTexture2D() SAFE_RELEASE(dsv); SAFE_RELEASE(tex); } + +} // namespace DX11 \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX11/Src/D3DTexture.h b/Source/Plugins/Plugin_VideoDX11/Src/D3DTexture.h index 3b0aed5a8b..9df78d31bb 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/D3DTexture.h +++ b/Source/Plugins/Plugin_VideoDX11/Src/D3DTexture.h @@ -17,7 +17,10 @@ #pragma once -#include "d3d11.h" +#include + +namespace DX11 +{ namespace D3D { @@ -53,3 +56,5 @@ private: D3D11_BIND_FLAG bindflags; UINT ref; }; + +} // namespace DX11 \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp b/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp index aea9e38e60..995a9e9a02 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.cpp @@ -24,6 +24,9 @@ #include "D3DShader.h" #include "GfxState.h" +namespace DX11 +{ + namespace D3D { @@ -690,4 +693,6 @@ void drawClearQuad(u32 Color, float z, ID3D11PixelShader* PShader, ID3D11VertexS context->Draw(4, clearq_offset); } -} // namespace +} // namespace D3D + +} // namespace DX11 diff --git a/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.h b/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.h index 135d6f1a3f..7f069164ea 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.h +++ b/Source/Plugins/Plugin_VideoDX11/Src/D3DUtil.h @@ -17,9 +17,12 @@ #pragma once -#include "d3d11.h" +#include #include +namespace DX11 +{ + namespace D3D { // Font creation flags @@ -83,3 +86,5 @@ namespace D3D void drawClearQuad(u32 Color, float z, ID3D11PixelShader* PShader, ID3D11VertexShader* Vshader, ID3D11InputLayout* layout); void drawColorQuad(u32 Color, float x1, float y1, float x2, float y2); } + +} \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX11/Src/FramebufferManager.cpp b/Source/Plugins/Plugin_VideoDX11/Src/FramebufferManager.cpp index 3b5ecb93e0..fb847c858e 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/FramebufferManager.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/FramebufferManager.cpp @@ -24,6 +24,8 @@ #include "Render.h" #include "VertexShaderCache.h" +namespace DX11 { + FramebufferManager::Efb FramebufferManager::m_efb; D3DTexture2D* &FramebufferManager::GetEFBColorTexture() { return m_efb.color_tex; } @@ -204,3 +206,5 @@ void XFBSource::CopyEFB(float Gamma) D3D::context->OMSetRenderTargets(1, &FramebufferManager::GetEFBColorTexture()->GetRTV(), FramebufferManager::GetEFBDepthTexture()->GetDSV()); } + +} // namespace DX11 \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX11/Src/FramebufferManager.h b/Source/Plugins/Plugin_VideoDX11/Src/FramebufferManager.h index 9039d91e1e..ab8b9b049d 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/FramebufferManager.h +++ b/Source/Plugins/Plugin_VideoDX11/Src/FramebufferManager.h @@ -24,6 +24,8 @@ #include "D3DTexture.h" +namespace DX11 { + // On the GameCube, the game sends a request for the graphics processor to // transfer its internal EFB (Embedded Framebuffer) to an area in GameCube RAM // called the XFB (External Framebuffer). The size and location of the XFB is @@ -105,4 +107,6 @@ private: } m_efb; }; +} // namespace DX11 + #endif diff --git a/Source/Plugins/Plugin_VideoDX11/Src/GfxState.cpp b/Source/Plugins/Plugin_VideoDX11/Src/GfxState.cpp index b0f89f652e..c5175d1275 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/GfxState.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/GfxState.cpp @@ -20,6 +20,9 @@ #include "D3DBase.h" #include "GfxState.h" +namespace DX11 +{ + namespace D3D { @@ -86,3 +89,5 @@ void StateManager::Apply() } } // namespace + +} // namespace DX11 \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX11/Src/GfxState.h b/Source/Plugins/Plugin_VideoDX11/Src/GfxState.h index bbdc18f724..4af093df9e 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/GfxState.h +++ b/Source/Plugins/Plugin_VideoDX11/Src/GfxState.h @@ -23,6 +23,9 @@ struct ID3D11BlendState; struct ID3D11DepthStencilState; struct ID3D11RasterizerState; +namespace DX11 +{ + namespace D3D { @@ -73,3 +76,5 @@ private: extern StateManager* stateman; } // namespace + +} // namespace DX11 \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX11/Src/NativeVertexFormat.cpp b/Source/Plugins/Plugin_VideoDX11/Src/NativeVertexFormat.cpp index c86b2a9448..6fd6f694eb 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/NativeVertexFormat.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/NativeVertexFormat.cpp @@ -27,7 +27,7 @@ class D3DVertexFormat : public NativeVertexFormat D3D11_INPUT_ELEMENT_DESC m_elems[32]; UINT m_num_elems; - D3DBlob* m_vs_bytecode; + DX11::D3DBlob* m_vs_bytecode; ID3D11InputLayout* m_layout; public: @@ -141,17 +141,17 @@ void D3DVertexFormat::Initialize(const PortableVertexDeclaration &_vtx_decl) void D3DVertexFormat::SetupVertexPointers() { - if (m_vs_bytecode != VertexShaderCache::GetActiveShaderBytecode()) + if (m_vs_bytecode != DX11::VertexShaderCache::GetActiveShaderBytecode()) { SAFE_RELEASE(m_vs_bytecode); SAFE_RELEASE(m_layout); - m_vs_bytecode = VertexShaderCache::GetActiveShaderBytecode(); + m_vs_bytecode = DX11::VertexShaderCache::GetActiveShaderBytecode(); m_vs_bytecode->AddRef(); - HRESULT hr = D3D::device->CreateInputLayout(m_elems, m_num_elems, m_vs_bytecode->Data(), m_vs_bytecode->Size(), &m_layout); + HRESULT hr = DX11::D3D::device->CreateInputLayout(m_elems, m_num_elems, m_vs_bytecode->Data(), m_vs_bytecode->Size(), &m_layout); if (FAILED(hr)) PanicAlert("Failed to create input layout, %s %d\n", __FILE__, __LINE__); - D3D::SetDebugObjectName((ID3D11DeviceChild*)m_layout, "input layout used to emulate the GX pipeline"); + DX11::D3D::SetDebugObjectName((ID3D11DeviceChild*)m_layout, "input layout used to emulate the GX pipeline"); } - D3D::context->IASetInputLayout(m_layout); + DX11::D3D::context->IASetInputLayout(m_layout); } diff --git a/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp index a61c8688a3..1a3140bc2a 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp @@ -30,6 +30,14 @@ extern int frameCount; +// See comment near the bottom of this file. +float psconstants[C_PENVCONST_END*4]; +bool pscbufchanged = true; + +namespace DX11 +{ + + PixelShaderCache::PSCache PixelShaderCache::PixelShaders; const PixelShaderCache::PSCacheEntry* PixelShaderCache::last_entry; @@ -39,9 +47,6 @@ ID3D11PixelShader* s_ColorMatrixProgram[2] = {NULL}; ID3D11PixelShader* s_ColorCopyProgram[2] = {NULL}; ID3D11PixelShader* s_DepthMatrixProgram[2] = {NULL}; ID3D11PixelShader* s_ClearProgram = NULL; - -float psconstants[C_PENVCONST_END*4]; -bool pscbufchanged = true; ID3D11Buffer* pscbuf = NULL; const char clear_program_code[] = { @@ -205,49 +210,6 @@ ID3D11PixelShader* PixelShaderCache::GetClearProgram() return s_ClearProgram; } -// HACK to avoid some invasive VideoCommon changes -// these values are hardcoded, they depend on internal D3DCompile behavior; TODO: Solve this with D3DReflect or something -// offset given in floats, table index is float4 -unsigned int ps_constant_offset_table[] = { - 0, 4, 8, 12, // C_COLORS, 16 - 16, 20, 24, 28, // C_KCOLORS, 16 - 32, // C_ALPHA, 4 - 36, 40, 44, 48, 52, 56, 60, 64, // C_TEXDIMS, 32 - 68, 72, // C_ZBIAS, 8 - 76, 80, // C_INDTEXSCALE, 8 - 84, 88, 92, 96, 100, 104, // C_INDTEXMTX, 24 - 108, 112, 116, // C_FOG, 12 - 120, 124, 128, 132, 136, // C_PLIGHTS0, 20 - 140, 144, 148, 152, 156, // C_PLIGHTS1, 20 - 160, 164, 168, 172, 176, // C_PLIGHTS2, 20 - 180, 184, 188, 192, 196, // C_PLIGHTS3, 20 - 200, 204, 208, 212, 216, // C_PLIGHTS4, 20 - 220, 224, 228, 232, 236, // C_PLIGHTS5, 20 - 240, 244, 248, 252, 256, // C_PLIGHTS6, 20 - 260, 264, 268, 272, 276, // C_PLIGHTS7, 20 - 280, 284, 288, 292 // C_PMATERIALS, 16 -}; -void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) -{ - psconstants[ps_constant_offset_table[const_number] ] = f1; - psconstants[ps_constant_offset_table[const_number]+1] = f2; - psconstants[ps_constant_offset_table[const_number]+2] = f3; - psconstants[ps_constant_offset_table[const_number]+3] = f4; - pscbufchanged = true; -} - -void SetPSConstant4fv(unsigned int const_number, const float* f) -{ - memcpy(&psconstants[ps_constant_offset_table[const_number]], f, sizeof(float)*4); - pscbufchanged = true; -} - -void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float* f) -{ - memcpy(&psconstants[ps_constant_offset_table[const_number]], f, sizeof(float)*4*count); - pscbufchanged = true; -} - ID3D11Buffer* &PixelShaderCache::GetConstantBuffer() { // TODO: divide the global variables of the generated shaders into about 5 constant buffers to speed this up @@ -422,4 +384,53 @@ bool PixelShaderCache::InsertByteCode(const PIXELSHADERUID &uid, const void* byt INCSTAT(stats.numPixelShadersCreated); SETSTAT(stats.numPixelShadersAlive, PixelShaders.size()); return true; -} \ No newline at end of file +} + +} // DX11 + + +// These are "callbacks" from VideoCommon and thus must be outside namespace DX11. +// This will have to be changed when we merge. + +// HACK to avoid some invasive VideoCommon changes +// these values are hardcoded, they depend on internal D3DCompile behavior; TODO: Solve this with D3DReflect or something +// offset given in floats, table index is float4 +static const unsigned int ps_constant_offset_table[] = { + 0, 4, 8, 12, // C_COLORS, 16 + 16, 20, 24, 28, // C_KCOLORS, 16 + 32, // C_ALPHA, 4 + 36, 40, 44, 48, 52, 56, 60, 64, // C_TEXDIMS, 32 + 68, 72, // C_ZBIAS, 8 + 76, 80, // C_INDTEXSCALE, 8 + 84, 88, 92, 96, 100, 104, // C_INDTEXMTX, 24 + 108, 112, 116, // C_FOG, 12 + 120, 124, 128, 132, 136, // C_PLIGHTS0, 20 + 140, 144, 148, 152, 156, // C_PLIGHTS1, 20 + 160, 164, 168, 172, 176, // C_PLIGHTS2, 20 + 180, 184, 188, 192, 196, // C_PLIGHTS3, 20 + 200, 204, 208, 212, 216, // C_PLIGHTS4, 20 + 220, 224, 228, 232, 236, // C_PLIGHTS5, 20 + 240, 244, 248, 252, 256, // C_PLIGHTS6, 20 + 260, 264, 268, 272, 276, // C_PLIGHTS7, 20 + 280, 284, 288, 292 // C_PMATERIALS, 16 +}; +void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) +{ + psconstants[ps_constant_offset_table[const_number] ] = f1; + psconstants[ps_constant_offset_table[const_number]+1] = f2; + psconstants[ps_constant_offset_table[const_number]+2] = f3; + psconstants[ps_constant_offset_table[const_number]+3] = f4; + pscbufchanged = true; +} + +void SetPSConstant4fv(unsigned int const_number, const float* f) +{ + memcpy(&psconstants[ps_constant_offset_table[const_number]], f, sizeof(float)*4); + pscbufchanged = true; +} + +void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float* f) +{ + memcpy(&psconstants[ps_constant_offset_table[const_number]], f, sizeof(float)*4*count); + pscbufchanged = true; +} diff --git a/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.h b/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.h index 874e9fb4c7..29454e73c3 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.h +++ b/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.h @@ -24,6 +24,8 @@ class PIXELSHADERUID; enum DSTALPHA_MODE; +namespace DX11 { + class PixelShaderCache { public: @@ -58,3 +60,5 @@ private: static PSCache PixelShaders; static const PSCacheEntry* last_entry; }; + +} // namespace DX11 \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp index 44879758c6..16454bbb08 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp @@ -40,6 +40,9 @@ #include "VertexShaderCache.h" +namespace DX11 +{ + static int s_fps = 0; static u32 s_LastAA = 0; @@ -305,9 +308,6 @@ void TeardownDeviceObjects() SAFE_RELEASE(resetraststate); } -namespace DX11 -{ - Renderer::Renderer() { int x, y, w_temp, h_temp; @@ -1340,4 +1340,4 @@ void Renderer::SetInterlacingMode() // TODO } -} +} // namespace DX11 \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX11/Src/VertexShaderCache.cpp b/Source/Plugins/Plugin_VideoDX11/Src/VertexShaderCache.cpp index 5640bdffb8..8f575aced7 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/VertexShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/VertexShaderCache.cpp @@ -26,6 +26,13 @@ #include "Globals.h" #include "VertexShaderCache.h" +// See comment near the bottom of this file +static unsigned int vs_constant_offset_table[C_VENVCONST_END]; +float vsconstants[C_VENVCONST_END*4]; +bool vscbufchanged = true; + +namespace DX11 { + VertexShaderCache::VSCache VertexShaderCache::vshaders; const VertexShaderCache::VSCacheEntry *VertexShaderCache::last_entry; @@ -41,43 +48,8 @@ ID3D11VertexShader* VertexShaderCache::GetClearVertexShader() { return ClearVert ID3D11InputLayout* VertexShaderCache::GetSimpleInputLayout() { return SimpleLayout; } ID3D11InputLayout* VertexShaderCache::GetClearInputLayout() { return ClearLayout; } -float vsconstants[C_VENVCONST_END*4]; -bool vscbufchanged = true; ID3D11Buffer* vscbuf = NULL; -// maps the constant numbers to float indices in the constant buffer -unsigned int vs_constant_offset_table[C_VENVCONST_END]; -void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) -{ - vsconstants[vs_constant_offset_table[const_number] ] = f1; - vsconstants[vs_constant_offset_table[const_number]+1] = f2; - vsconstants[vs_constant_offset_table[const_number]+2] = f3; - vsconstants[vs_constant_offset_table[const_number]+3] = f4; - vscbufchanged = true; -} - -void SetVSConstant4fv(unsigned int const_number, const float* f) -{ - memcpy(&vsconstants[vs_constant_offset_table[const_number]], f, sizeof(float)*4); - vscbufchanged = true; -} - -void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float* f) -{ - for (unsigned int i = 0; i < count; i++) - { - memcpy(&vsconstants[vs_constant_offset_table[const_number+i]], f+3*i, sizeof(float)*3); - vsconstants[vs_constant_offset_table[const_number+i]+3] = 0.f; - } - vscbufchanged = true; -} - -void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float* f) -{ - memcpy(&vsconstants[vs_constant_offset_table[const_number]], f, sizeof(float)*4*count); - vscbufchanged = true; -} - ID3D11Buffer* &VertexShaderCache::GetConstantBuffer() { // TODO: divide the global variables of the generated shaders into about 5 constant buffers to speed this up @@ -292,3 +264,39 @@ bool VertexShaderCache::InsertByteCode(const VERTEXSHADERUID &uid, D3DBlob* bcod return true; } +} // namespace DX11 + +// These are "callbacks" from VideoCommon and thus must be outside namespace DX11. +// This will have to be changed when we merge. + +// maps the constant numbers to float indices in the constant buffer +void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) +{ + vsconstants[vs_constant_offset_table[const_number] ] = f1; + vsconstants[vs_constant_offset_table[const_number]+1] = f2; + vsconstants[vs_constant_offset_table[const_number]+2] = f3; + vsconstants[vs_constant_offset_table[const_number]+3] = f4; + vscbufchanged = true; +} + +void SetVSConstant4fv(unsigned int const_number, const float* f) +{ + memcpy(&vsconstants[vs_constant_offset_table[const_number]], f, sizeof(float)*4); + vscbufchanged = true; +} + +void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float* f) +{ + for (unsigned int i = 0; i < count; i++) + { + memcpy(&vsconstants[vs_constant_offset_table[const_number+i]], f+3*i, sizeof(float)*3); + vsconstants[vs_constant_offset_table[const_number+i]+3] = 0.f; + } + vscbufchanged = true; +} + +void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float* f) +{ + memcpy(&vsconstants[vs_constant_offset_table[const_number]], f, sizeof(float)*4*count); + vscbufchanged = true; +} \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX11/Src/VertexShaderCache.h b/Source/Plugins/Plugin_VideoDX11/Src/VertexShaderCache.h index c993eb2429..3c7dadd3e7 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/VertexShaderCache.h +++ b/Source/Plugins/Plugin_VideoDX11/Src/VertexShaderCache.h @@ -25,6 +25,8 @@ class VERTEXSHADERUID; +namespace DX11 { + class VertexShaderCache { public: @@ -70,4 +72,6 @@ private: static const VSCacheEntry* last_entry; }; +} // namespace DX11 + #endif // _VERTEXSHADERCACHE_H diff --git a/Source/Plugins/Plugin_VideoDX11/Src/main.cpp b/Source/Plugins/Plugin_VideoDX11/Src/main.cpp index 960277f806..49c174bf5d 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/main.cpp @@ -180,17 +180,17 @@ void DllConfig(void *_hParent) #if defined(HAVE_WX) && HAVE_WX InitBackendInfo(); - HRESULT hr = D3D::LoadDXGI(); - if (SUCCEEDED(hr)) hr = D3D::LoadD3D(); + HRESULT hr = DX11::D3D::LoadDXGI(); + if (SUCCEEDED(hr)) hr = DX11::D3D::LoadD3D(); if (FAILED(hr)) { - D3D::UnloadDXGI(); + DX11::D3D::UnloadDXGI(); return; } IDXGIFactory* factory; IDXGIAdapter* ad; - hr = PCreateDXGIFactory(__uuidof(IDXGIFactory), (void**)&factory); + hr = DX11::PCreateDXGIFactory(__uuidof(IDXGIFactory), (void**)&factory); if (FAILED(hr)) PanicAlert("Failed to create IDXGIFactory object"); @@ -209,7 +209,7 @@ void DllConfig(void *_hParent) { char buf[32]; std::vector modes; - D3D::EnumAAModes(ad, modes); + DX11::D3D::EnumAAModes(ad, modes); for (unsigned int i = 0; i < modes.size(); ++i) { if (i == 0) sprintf_s(buf, 32, "None"); @@ -229,8 +229,8 @@ void DllConfig(void *_hParent) diag->ShowModal(); diag->Destroy(); - D3D::UnloadDXGI(); - D3D::UnloadD3D(); + DX11::D3D::UnloadDXGI(); + DX11::D3D::UnloadD3D(); #endif } @@ -279,9 +279,9 @@ void Video_Prepare() g_renderer = new DX11::Renderer; g_texture_cache = new DX11::TextureCache; g_vertex_manager = new DX11::VertexManager; - VertexShaderCache::Init(); - PixelShaderCache::Init(); - D3D::InitUtils(); + DX11::VertexShaderCache::Init(); + DX11::PixelShaderCache::Init(); + DX11::D3D::InitUtils(); // VideoCommon BPInit(); @@ -316,9 +316,9 @@ void Shutdown() VertexLoaderManager::Shutdown(); // internal interfaces - D3D::ShutdownUtils(); - PixelShaderCache::Shutdown(); - VertexShaderCache::Shutdown(); + DX11::D3D::ShutdownUtils(); + DX11::PixelShaderCache::Shutdown(); + DX11::VertexShaderCache::Shutdown(); delete g_vertex_manager; delete g_texture_cache; delete g_renderer; diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.cpp b/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.cpp index 5eddcf2b63..dee255f4cc 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.cpp @@ -22,11 +22,15 @@ #include "StringUtil.h" #include "VideoCommon.h" -// D3DX -HINSTANCE hD3DXDll = NULL; D3DXSAVESURFACETOFILEATYPE PD3DXSaveSurfaceToFileA = NULL; D3DXSAVETEXTURETOFILEATYPE PD3DXSaveTextureToFileA = NULL; D3DXCOMPILESHADERTYPE PD3DXCompileShader = NULL; + +namespace DX9 +{ + +// D3DX +HINSTANCE hD3DXDll = NULL; int d3dx_dll_ref = 0; typedef IDirect3D9* (WINAPI* DIRECT3DCREATE9)(UINT); @@ -820,3 +824,5 @@ void SetPixelShader(LPDIRECT3DPIXELSHADER9 shader) } // namespace + +} // namespace DX9 \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.h b/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.h index c337c8ab0e..f4a5244dbe 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.h @@ -15,8 +15,7 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ -#ifndef _D3DBASE_H -#define _D3DBASE_H +#pragma once #include #include @@ -25,6 +24,9 @@ #include "Common.h" +namespace DX9 +{ + namespace D3D { @@ -151,6 +153,8 @@ int GetNumAdapters(); } // namespace +} // namespace DX9 + // Used to not require the SDK and runtime versions to match: // Linking with d3dx9.lib makes the most recent d3dx9_xx.dll of the @@ -163,7 +167,3 @@ typedef HRESULT (WINAPI* D3DXCOMPILESHADERTYPE)(LPCSTR, UINT, CONST D3DXMACRO*, extern D3DXSAVESURFACETOFILEATYPE PD3DXSaveSurfaceToFileA; extern D3DXSAVETEXTURETOFILEATYPE PD3DXSaveTextureToFileA; extern D3DXCOMPILESHADERTYPE PD3DXCompileShader; - - - -#endif diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DShader.cpp b/Source/Plugins/Plugin_VideoDX9/Src/D3DShader.cpp index f3fec31e9d..b2bb44a920 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DShader.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DShader.cpp @@ -21,6 +21,9 @@ #include "VideoConfig.h" #include "D3DShader.h" +namespace DX9 +{ + namespace D3D { @@ -151,3 +154,5 @@ LPDIRECT3DPIXELSHADER9 CompileAndCreatePixelShader(const char* code, unsigned in } } // namespace + +} // namespace DX9 \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DShader.h b/Source/Plugins/Plugin_VideoDX9/Src/D3DShader.h index 32bdb145e7..94e9a4a418 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DShader.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DShader.h @@ -19,6 +19,9 @@ #include "D3DBase.h" +namespace DX9 +{ + namespace D3D { LPDIRECT3DVERTEXSHADER9 CreateVertexShaderFromByteCode(const u8 *bytecode, int len); @@ -32,3 +35,5 @@ namespace D3D LPDIRECT3DVERTEXSHADER9 CompileAndCreateVertexShader(const char *code, int len); LPDIRECT3DPIXELSHADER9 CompileAndCreatePixelShader(const char *code, unsigned int len); } + +} // namespace DX9 \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DTexture.cpp b/Source/Plugins/Plugin_VideoDX9/Src/D3DTexture.cpp index c379506f84..25c1313ae8 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DTexture.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DTexture.cpp @@ -27,6 +27,9 @@ #include #endif +namespace DX9 +{ + namespace D3D { @@ -412,3 +415,5 @@ void ReplaceTexture2D(LPDIRECT3DTEXTURE9 pTexture, const u8* buffer, const int w } } // namespace + +} // namespace DX9 \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DTexture.h b/Source/Plugins/Plugin_VideoDX9/Src/D3DTexture.h index c9c139a218..c7ab754d6d 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DTexture.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DTexture.h @@ -19,6 +19,9 @@ #include "D3DBase.h" +namespace DX9 +{ + namespace D3D { LPDIRECT3DTEXTURE9 CreateTexture2D(const u8* buffer, const int width, const int height, const int pitch, D3DFORMAT fmt = D3DFMT_A8R8G8B8, bool swap_r_b = false, int levels = 1); @@ -27,3 +30,5 @@ namespace D3D LPDIRECT3DSURFACE9 CreateDepthStencilSurface(const int width, const int height); LPDIRECT3DTEXTURE9 CreateOnlyTexture2D(const int width, const int height, D3DFORMAT fmt); } + +} // namespace DX9 diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp index 5763989dc8..3a4b5d0699 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp @@ -24,6 +24,9 @@ #include "PixelShaderCache.h" #include "VertexShaderCache.h" +namespace DX9 +{ + namespace D3D { CD3DFont font; @@ -463,3 +466,5 @@ void drawClearQuad(u32 Color,float z,IDirect3DPixelShader9 *PShader,IDirect3DVer } // namespace + +} // namespace DX9 diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.h b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.h index dd5b356091..882f112ece 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.h @@ -21,6 +21,9 @@ #include #include +namespace DX9 +{ + namespace D3D { // Font creation flags @@ -85,3 +88,5 @@ namespace D3D void SaveRenderStates(); void RestoreRenderStates(); } + +} // namespace DX9 \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.cpp b/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.cpp index 89d4514972..086a2f794f 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.cpp @@ -23,6 +23,9 @@ #include "VertexShaderCache.h" #include "TextureConverter.h" +namespace DX9 +{ + // TODO: this is probably somewhere else #define SAFE_RELEASE(p) if (p) { (p)->Release(); (p) = NULL; } @@ -229,3 +232,5 @@ void XFBSource::CopyEFB(float Gamma) Rendersurf->Release(); } + +} // namespace DX9 diff --git a/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.h b/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.h index 7d83b78f4f..5b5993a12b 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.h @@ -15,8 +15,7 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ -#ifndef _FRAMEBUFFERMANAGER_D3D_H_ -#define _FRAMEBUFFERMANAGER_D3D_H_ +#pragma once #include "D3DBase.h" #include "FramebufferManagerBase.h" @@ -50,6 +49,9 @@ // Disadvantages: If the GameCube CPU writes directly to the XFB (which is // possible but uncommon), the Virtual XFB will not capture this information. +namespace DX9 +{ + struct XFBSource : public XFBSourceBase { XFBSource(LPDIRECT3DTEXTURE9 tex) : texture(tex) {} @@ -133,4 +135,4 @@ private: } s_efb; }; -#endif +} // namespace DX9 \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX9/Src/NativeVertexFormat.cpp b/Source/Plugins/Plugin_VideoDX9/Src/NativeVertexFormat.cpp index f10e38ce8c..e011e766aa 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/NativeVertexFormat.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/NativeVertexFormat.cpp @@ -173,7 +173,7 @@ void D3DVertexFormat::Initialize(const PortableVertexDeclaration &_vtx_decl) elems[elem_idx].Type = D3DDECLTYPE_UNUSED; ++elem_idx; - if (FAILED(D3D::dev->CreateVertexDeclaration(elems, &d3d_decl))) + if (FAILED(DX9::D3D::dev->CreateVertexDeclaration(elems, &d3d_decl))) { PanicAlert("Failed to create D3D vertex declaration!"); return; @@ -187,7 +187,7 @@ void D3DVertexFormat::Initialize(const PortableVertexDeclaration &_vtx_decl) void D3DVertexFormat::SetupVertexPointers() { if (d3d_decl) - D3D::SetVertexDeclaration(d3d_decl); + DX9::D3D::SetVertexDeclaration(d3d_decl); else ERROR_LOG(VIDEO, "invalid d3d decl"); } diff --git a/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.cpp index 904763f71e..b298a22223 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.cpp @@ -37,6 +37,9 @@ #include "ImageWrite.h" #include "Debugger.h" +namespace DX9 +{ + PixelShaderCache::PSCache PixelShaderCache::PixelShaders; const PixelShaderCache::PSCacheEntry *PixelShaderCache::last_entry; @@ -62,6 +65,15 @@ static LPDIRECT3DPIXELSHADER9 s_ClearProgram = NULL; static LPDIRECT3DPIXELSHADER9 s_rgba6_to_rgb8 = NULL; static LPDIRECT3DPIXELSHADER9 s_rgb8_to_rgba6 = NULL; +class PixelShaderCacheInserter : public LinearDiskCacheReader +{ +public: + void Read(const PIXELSHADERUID &key, const u8 *value, u32 value_size) + { + PixelShaderCache::InsertByteCode(key, value, value_size, false); + } +}; + LPDIRECT3DPIXELSHADER9 PixelShaderCache::GetColorMatrixProgram(int SSAAMode) { return s_CopyProgram[COPY_TYPE_MATRIXCOLOR][DEPTH_CONVERSION_TYPE_NONE][SSAAMode % MAX_SSAA_SHADERS]; @@ -141,31 +153,6 @@ LPDIRECT3DPIXELSHADER9 PixelShaderCache::ReinterpRGB8ToRGBA6() return s_rgb8_to_rgba6; } -void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) -{ - float f[4] = { f1, f2, f3, f4 }; - D3D::dev->SetPixelShaderConstantF(const_number, f, 1); -} - -void SetPSConstant4fv(unsigned int const_number, const float *f) -{ - D3D::dev->SetPixelShaderConstantF(const_number, f, 1); -} - -void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f) -{ - D3D::dev->SetPixelShaderConstantF(const_number, f, count); -} - -class PixelShaderCacheInserter : public LinearDiskCacheReader -{ -public: - void Read(const PIXELSHADERUID &key, const u8 *value, u32 value_size) - { - PixelShaderCache::InsertByteCode(key, value, value_size, false); - } -}; - #define WRITE p+=sprintf static LPDIRECT3DPIXELSHADER9 CreateCopyShader(int copyMatrixType, int depthConversionType, int SSAAMode) @@ -430,3 +417,22 @@ bool PixelShaderCache::InsertByteCode(const PIXELSHADERUID &uid, const u8 *bytec } return true; } + +} // namespace DX9 + + +void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) +{ + float f[4] = { f1, f2, f3, f4 }; + DX9::D3D::dev->SetPixelShaderConstantF(const_number, f, 1); +} + +void SetPSConstant4fv(unsigned int const_number, const float *f) +{ + DX9::D3D::dev->SetPixelShaderConstantF(const_number, f, 1); +} + +void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f) +{ + DX9::D3D::dev->SetPixelShaderConstantF(const_number, f, count); +} diff --git a/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.h b/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.h index e5da3265a4..2f3c552e2a 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.h @@ -15,8 +15,7 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ -#ifndef _PIXELSHADERCACHE_H -#define _PIXELSHADERCACHE_H +#pragma once #include "Common.h" #include "LinearDiskCache.h" @@ -27,6 +26,9 @@ #include "PixelShaderGen.h" #include "VertexShaderGen.h" +namespace DX9 +{ + typedef u32 tevhash; tevhash GetCurrentTEV(); @@ -68,5 +70,4 @@ public: static LPDIRECT3DPIXELSHADER9 ReinterpRGB8ToRGBA6(); }; - -#endif // _PIXELSHADERCACHE_H +} // namespace DX9 \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp index 2d2415a1b6..bf4d29e261 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp @@ -51,6 +51,9 @@ #include "DLCache.h" #include "Debugger.h" +namespace DX9 +{ + static int s_fps = 0; static int s_recordWidth; @@ -243,9 +246,6 @@ void TeardownDeviceObjects() TextureConverter::Shutdown(); } -namespace DX9 -{ - // Init functions Renderer::Renderer() { @@ -1397,4 +1397,4 @@ void Renderer::SetInterlacingMode() // TODO } -} +} // namespace DX9 diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.h b/Source/Plugins/Plugin_VideoDX9/Src/Render.h index 94f51b21d5..bd2c65bac4 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.h @@ -50,6 +50,6 @@ public: static void SetWindowSize(int width, int height); }; -} +} // namespace DX9 #endif diff --git a/Source/Plugins/Plugin_VideoDX9/Src/TextureConverter.cpp b/Source/Plugins/Plugin_VideoDX9/Src/TextureConverter.cpp index b5d97d2a7b..a0619270a0 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/TextureConverter.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/TextureConverter.cpp @@ -32,6 +32,9 @@ #include "Math.h" #include "FileUtil.h" +namespace DX9 +{ + namespace TextureConverter { struct TransformBuffer @@ -549,3 +552,5 @@ void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, LPDIRECT3DTEXTURE } } // namespace + +} // namespace DX9 \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX9/Src/TextureConverter.h b/Source/Plugins/Plugin_VideoDX9/Src/TextureConverter.h index 7ea22bec3f..aa4757e4c9 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/TextureConverter.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/TextureConverter.h @@ -24,7 +24,10 @@ #include "D3DUtil.h" #include "D3DShader.h" -// Converts textures between formats +namespace DX9 +{ + +// Converts textures between formats using shaders // TODO: support multiple texture formats namespace TextureConverter { @@ -45,4 +48,6 @@ u64 EncodeToRamFromTexture(u32 address,LPDIRECT3DTEXTURE9 source_texture, u32 So } +} // namespace DX9 + #endif // _TEXTURECONVERTER_H_ diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp b/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp index 3ffecc8377..ea77072e7a 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp @@ -32,6 +32,9 @@ #include "XFMemory.h" #include "Debugger.h" +namespace DX9 +{ + VertexShaderCache::VSCache VertexShaderCache::vshaders; const VertexShaderCache::VSCacheEntry *VertexShaderCache::last_entry; @@ -52,35 +55,6 @@ LPDIRECT3DVERTEXSHADER9 VertexShaderCache::GetClearVertexShader() return ClearVertexShader; } -void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) -{ - const float f[4] = { f1, f2, f3, f4 }; - D3D::dev->SetVertexShaderConstantF(const_number, f, 1); -} - -void SetVSConstant4fv(unsigned int const_number, const float *f) -{ - D3D::dev->SetVertexShaderConstantF(const_number, f, 1); -} - -void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f) -{ - float buf[4*C_VENVCONST_END]; - for (unsigned int i = 0; i < count; i++) - { - buf[4*i ] = *f++; - buf[4*i+1] = *f++; - buf[4*i+2] = *f++; - buf[4*i+3] = 0.f; - } - D3D::dev->SetVertexShaderConstantF(const_number, buf, count); -} - -void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f) -{ - D3D::dev->SetVertexShaderConstantF(const_number, f, count); -} - // this class will load the precompiled shaders into our cache class VertexShaderCacheInserter : public LinearDiskCacheReader { @@ -271,3 +245,35 @@ bool VertexShaderCache::InsertByteCode(const VERTEXSHADERUID &uid, const u8 *byt } return false; } + +} // namespace DX9 + + +void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) +{ + const float f[4] = { f1, f2, f3, f4 }; + DX9::D3D::dev->SetVertexShaderConstantF(const_number, f, 1); +} + +void SetVSConstant4fv(unsigned int const_number, const float *f) +{ + DX9::D3D::dev->SetVertexShaderConstantF(const_number, f, 1); +} + +void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f) +{ + float buf[4*C_VENVCONST_END]; + for (unsigned int i = 0; i < count; i++) + { + buf[4*i ] = *f++; + buf[4*i+1] = *f++; + buf[4*i+2] = *f++; + buf[4*i+3] = 0.f; + } + DX9::D3D::dev->SetVertexShaderConstantF(const_number, buf, count); +} + +void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f) +{ + DX9::D3D::dev->SetVertexShaderConstantF(const_number, f, count); +} diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.h b/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.h index 63564fee07..b516f46f9a 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.h @@ -15,8 +15,7 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ -#ifndef _VERTEXSHADERCACHE_H -#define _VERTEXSHADERCACHE_H +#pragma once #include "D3DBase.h" @@ -26,6 +25,9 @@ #include "D3DBase.h" #include "VertexShaderGen.h" +namespace DX9 +{ + class VertexShaderCache { private: @@ -62,4 +64,4 @@ public: static std::string GetCurrentShaderCode(); }; -#endif // _VERTEXSHADERCACHE_H +} // namespace DX9 \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX9/Src/main.cpp b/Source/Plugins/Plugin_VideoDX9/Src/main.cpp index 2cb376fe57..04bc607dba 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/main.cpp @@ -185,7 +185,7 @@ void InitBackendInfo() g_Config.backend_info.bAllowSignedBytes = false; g_Config.backend_info.bSupportsDualSourceBlend = false; g_Config.backend_info.bSupportsFormatReinterpretation = true; - int shaderModel = ((D3D::GetCaps().PixelShaderVersion >> 8) & 0xFF); + int shaderModel = ((DX9::D3D::GetCaps().PixelShaderVersion >> 8) & 0xFF); int maxConstants = (shaderModel < 3) ? 32 : ((shaderModel < 4) ? 224 : 65536); g_Config.backend_info.bSupportsPixelLighting = C_PLIGHTS + 40 <= maxConstants && C_PMATERIALS + 4 <= maxConstants; } @@ -194,18 +194,18 @@ void DllConfig(void *_hParent) { #if defined(HAVE_WX) && HAVE_WX InitBackendInfo(); - D3D::Init(); + DX9::D3D::Init(); // adapters g_Config.backend_info.Adapters.clear(); - for (int i = 0; i < D3D::GetNumAdapters(); ++i) - g_Config.backend_info.Adapters.push_back(D3D::GetAdapter(i).ident.Description); + for (int i = 0; i < DX9::D3D::GetNumAdapters(); ++i) + g_Config.backend_info.Adapters.push_back(DX9::D3D::GetAdapter(i).ident.Description); // aamodes g_Config.backend_info.AAModes.clear(); - if (g_Config.iAdapter < D3D::GetNumAdapters()) + if (g_Config.iAdapter < DX9::D3D::GetNumAdapters()) { - const D3D::Adapter &adapter = D3D::GetAdapter(g_Config.iAdapter); + const DX9::D3D::Adapter &adapter = DX9::D3D::GetAdapter(g_Config.iAdapter); for (int i = 0; i < (int)adapter.aa_levels.size(); ++i) g_Config.backend_info.AAModes.push_back(adapter.aa_levels[i].name); @@ -216,7 +216,7 @@ void DllConfig(void *_hParent) diag->ShowModal(); diag->Destroy(); - D3D::Shutdown(); + DX9::D3D::Shutdown(); #endif } @@ -241,7 +241,7 @@ void Initialize(void *init) ERROR_LOG(VIDEO, "An error has occurred while trying to create the window."); return; } - else if (FAILED(D3D::Init())) + else if (FAILED(DX9::D3D::Init())) { MessageBox(GetActiveWindow(), _T("Unable to initialize Direct3D. Please make sure that you have the latest version of DirectX 9.0c correctly installed."), _T("Fatal Error"), MB_ICONERROR|MB_OK); return; @@ -304,11 +304,11 @@ void Shutdown() VertexLoaderManager::Shutdown(); // internal interfaces - PixelShaderCache::Shutdown(); - VertexShaderCache::Shutdown(); + DX9::PixelShaderCache::Shutdown(); + DX9::VertexShaderCache::Shutdown(); delete g_vertex_manager; delete g_texture_cache; delete g_renderer; - D3D::Shutdown(); + DX9::D3D::Shutdown(); EmuWindow::Close(); } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/FramebufferManager.cpp b/Source/Plugins/Plugin_VideoOGL/Src/FramebufferManager.cpp index fd8350234f..2a6457f224 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/FramebufferManager.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/FramebufferManager.cpp @@ -21,7 +21,12 @@ #include "TextureConverter.h" #include "Render.h" -extern bool s_bHaveFramebufferBlit; // comes from Render.cpp + + +namespace OGL +{ + +extern bool s_bHaveFramebufferBlit; // comes from Render.cpp. ugly. int FramebufferManager::m_targetWidth; int FramebufferManager::m_targetHeight; @@ -401,3 +406,5 @@ void FramebufferManager::GetTargetSize(unsigned int *width, unsigned int *height *width = m_targetWidth; *height = m_targetHeight; } + +} // namespace OGL \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoOGL/Src/FramebufferManager.h b/Source/Plugins/Plugin_VideoOGL/Src/FramebufferManager.h index a174b8b808..ffe3399705 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/FramebufferManager.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/FramebufferManager.h @@ -53,6 +53,8 @@ // There may be multiple XFBs in GameCube RAM. This is the maximum number to // virtualize. +namespace OGL { + struct XFBSource : public XFBSourceBase { XFBSource(GLuint tex) : texture(tex) {} @@ -118,4 +120,6 @@ private: static GLuint m_xfbFramebuffer; // Only used in MSAA mode }; +} // namespace OGL + #endif diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp index 189ab9e9c3..32c53ac635 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp @@ -32,6 +32,9 @@ #include "FileUtil.h" #include "Debugger.h" +namespace OGL +{ + static int s_nMaxPixelInstructions; static GLuint s_ColorMatrixProgram = 0; static GLuint s_DepthMatrixProgram = 0; @@ -53,23 +56,6 @@ GLuint PixelShaderCache::GetColorMatrixProgram() return s_ColorMatrixProgram; } -void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) -{ - float f[4] = { f1, f2, f3, f4 }; - glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number, f); -} - -void SetPSConstant4fv(unsigned int const_number, const float *f) -{ - glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number, f); -} - -void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f) -{ - for (unsigned int i = 0; i < count; i++,f+=4) - glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number + i, f); -} - void PixelShaderCache::Init() { glEnable(GL_FRAGMENT_PROGRAM_ARB); @@ -354,3 +340,23 @@ void PixelShaderCache::SetCurrentShader(GLuint Shader) glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, CurrentShader); } } + +} // namespace OGL + + +void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) +{ + float f[4] = { f1, f2, f3, f4 }; + glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number, f); +} + +void SetPSConstant4fv(unsigned int const_number, const float *f) +{ + glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number, f); +} + +void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f) +{ + for (unsigned int i = 0; i < count; i++,f+=4) + glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number + i, f); +} diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.h b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.h index 8fd4b63ee6..f404b206a2 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.h @@ -24,6 +24,9 @@ #include "BPMemory.h" #include "PixelShaderGen.h" +namespace OGL +{ + struct FRAGMENTSHADER { FRAGMENTSHADER() : glprogid(0) { } @@ -83,4 +86,6 @@ public: static void DisableShader(); }; +} // namespace OGL + #endif // _PIXELSHADERCACHE_H_ diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PostProcessing.cpp b/Source/Plugins/Plugin_VideoOGL/Src/PostProcessing.cpp index 4be24195e0..2eb553a551 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/PostProcessing.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/PostProcessing.cpp @@ -22,6 +22,9 @@ #include "PostProcessing.h" #include "PixelShaderCache.h" +namespace OGL +{ + namespace PostProcessing { @@ -85,3 +88,5 @@ bool ApplyShader() } } // namespace + +} // namespace OGL \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PostProcessing.h b/Source/Plugins/Plugin_VideoOGL/Src/PostProcessing.h index 79a3d0a735..5d667e2b0a 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/PostProcessing.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/PostProcessing.h @@ -21,6 +21,9 @@ #include "VideoCommon.h" #include "GLUtil.h" +namespace OGL +{ + namespace PostProcessing { @@ -33,4 +36,6 @@ bool ApplyShader(); } // namespace +} // namespace + #endif // _POSTPROCESSING_H_ diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index d293097baf..cb9adf9b60 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -70,9 +70,23 @@ #include #endif -// Declarations and definitions -// ---------------------------- -int s_fps=0; + + +void VideoConfig::UpdateProjectionHack() +{ + ::UpdateProjectionHack(g_Config.iPhackvalue); +} + + +#if defined(HAVE_WX) && HAVE_WX +// Screenshot thread struct +typedef struct +{ + int W, H; + std::string filename; + wxImage *img; +} ScrStrct; +#endif #if defined HAVE_CG && HAVE_CG CGcontext g_cgcontext; @@ -80,6 +94,20 @@ CGprofile g_cgvProf; CGprofile g_cgfProf; #endif +#ifdef _WIN32 +extern int OSDChoice, OSDTime, OSDInternalW, OSDInternalH; +#else +int OSDChoice, OSDTime, OSDInternalW, OSDInternalH; +#endif + +namespace OGL +{ + +// Declarations and definitions +// ---------------------------- +int s_fps=0; + + RasterFont* s_pfont = NULL; #if defined _WIN32 || defined HAVE_LIBAV @@ -100,24 +128,6 @@ static u32 s_blendMode; static std::thread scrshotThread; #endif -#ifdef _WIN32 -extern int OSDChoice, OSDTime, OSDInternalW, OSDInternalH; -#else -int OSDChoice, OSDTime, OSDInternalW, OSDInternalH; -#endif - -namespace -{ - -#if defined(HAVE_WX) && HAVE_WX -// Screenshot thread struct -typedef struct -{ - int W, H; - std::string filename; - wxImage *img; -} ScrStrct; -#endif static const GLenum glSrcFactors[8] = { @@ -182,15 +192,6 @@ void HandleCgError(CGcontext ctx, CGerror err, void* appdata) } #endif -} // namespace -void VideoConfig::UpdateProjectionHack() -{ - ::UpdateProjectionHack(g_Config.iPhackvalue); -} - -namespace OGL -{ - // Init functions Renderer::Renderer() { diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp index 0308d07f9e..2bf9371cde 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp @@ -31,6 +31,9 @@ #include #include "FileUtil.h" +namespace OGL +{ + namespace TextureConverter { @@ -469,3 +472,5 @@ void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, GLuint destTextur } } // namespace + +} // namespace OGL \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.h b/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.h index 2c305f8ef7..719ac1b7fc 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.h @@ -21,7 +21,10 @@ #include "VideoCommon.h" #include "GLUtil.h" -// Converts textures between formats +namespace OGL +{ + +// Converts textures between formats using shaders // TODO: support multiple texture formats namespace TextureConverter { @@ -41,4 +44,6 @@ u64 EncodeToRamFromTexture(u32 address, GLuint source_texture, bool bFromZBuffer } +} // namespace OGL + #endif // _TEXTURECONVERTER_H_ diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp index 33153c73fc..3948e592de 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp @@ -34,6 +34,9 @@ #include "FileUtil.h" #include "Debugger.h" +namespace OGL +{ + VertexShaderCache::VSCache VertexShaderCache::vshaders; bool VertexShaderCache::s_displayCompileAlert; GLuint VertexShaderCache::CurrentShader; @@ -42,57 +45,6 @@ bool VertexShaderCache::ShaderEnabled; static VERTEXSHADER *pShaderLast = NULL; static int s_nMaxVertexInstructions; -void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) -{ - glProgramEnvParameter4fARB(GL_VERTEX_PROGRAM_ARB, const_number, f1, f2, f3, f4); -} - -void SetVSConstant4fv(unsigned int const_number, const float *f) -{ - glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, const_number, f); -} - -void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f) -{ - if(GLEW_EXT_gpu_program_parameters) - { - glProgramEnvParameters4fvEXT(GL_VERTEX_PROGRAM_ARB, const_number, count, f); - } - else - { - for (unsigned int i = 0; i < count; i++,f+=4) - glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, const_number + i, f); - } -} - -void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f) -{ - if(GLEW_EXT_gpu_program_parameters) - { - float buf[4 * C_VENVCONST_END]; - for (unsigned int i = 0; i < count; i++) - { - buf[4*i ] = *f++; - buf[4*i+1] = *f++; - buf[4*i+2] = *f++; - buf[4*i+3] = 0.f; - } - glProgramEnvParameters4fvEXT(GL_VERTEX_PROGRAM_ARB, const_number, count, buf); - } - else - { - for (unsigned int i = 0; i < count; i++) - { - float buf[4]; - buf[0] = *f++; - buf[1] = *f++; - buf[2] = *f++; - buf[3] = 0.f; - glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, const_number + i, buf); - } - } -} - void VertexShaderCache::Init() { @@ -257,3 +209,56 @@ void VertexShaderCache::SetCurrentShader(GLuint Shader) glBindProgramARB(GL_VERTEX_PROGRAM_ARB, CurrentShader); } } + +} // namespace OGL + +void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) +{ + glProgramEnvParameter4fARB(GL_VERTEX_PROGRAM_ARB, const_number, f1, f2, f3, f4); +} + +void SetVSConstant4fv(unsigned int const_number, const float *f) +{ + glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, const_number, f); +} + +void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f) +{ + if(GLEW_EXT_gpu_program_parameters) + { + glProgramEnvParameters4fvEXT(GL_VERTEX_PROGRAM_ARB, const_number, count, f); + } + else + { + for (unsigned int i = 0; i < count; i++,f+=4) + glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, const_number + i, f); + } +} + +void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f) +{ + if(GLEW_EXT_gpu_program_parameters) + { + float buf[4 * C_VENVCONST_END]; + for (unsigned int i = 0; i < count; i++) + { + buf[4*i ] = *f++; + buf[4*i+1] = *f++; + buf[4*i+2] = *f++; + buf[4*i+3] = 0.f; + } + glProgramEnvParameters4fvEXT(GL_VERTEX_PROGRAM_ARB, const_number, count, buf); + } + else + { + for (unsigned int i = 0; i < count; i++) + { + float buf[4]; + buf[0] = *f++; + buf[1] = *f++; + buf[2] = *f++; + buf[3] = 0.f; + glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, const_number + i, buf); + } + } +} diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.h b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.h index c024a9ee4f..9ada76fd3b 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.h @@ -24,6 +24,9 @@ #include "BPMemory.h" #include "VertexShaderGen.h" +namespace OGL +{ + struct VERTEXSHADER { VERTEXSHADER() : glprogid(0) {} @@ -69,4 +72,6 @@ public: }; +} // namespace OGL + #endif // _VERTEXSHADERCACHE_H_ diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index 81c3739596..b39540cc6a 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -311,14 +311,14 @@ void Video_Prepare() g_vertex_manager = new OGL::VertexManager; Fifo_Init(); // must be done before OpcodeDecoder_Init() OpcodeDecoder_Init(); - VertexShaderCache::Init(); + OGL::VertexShaderCache::Init(); VertexShaderManager::Init(); - PixelShaderCache::Init(); + OGL::PixelShaderCache::Init(); PixelShaderManager::Init(); - PostProcessing::Init(); + OGL::PostProcessing::Init(); GL_REPORT_ERRORD(); VertexLoaderManager::Init(); - TextureConverter::Init(); + OGL::TextureConverter::Init(); DLCache::Init(); // Notify the core that the video plugin is ready @@ -338,16 +338,16 @@ void Shutdown() s_swapRequested = FALSE; DLCache::Shutdown(); Fifo_Shutdown(); - PostProcessing::Shutdown(); + OGL::PostProcessing::Shutdown(); // The following calls are NOT Thread Safe // And need to be called from the video thread - TextureConverter::Shutdown(); + OGL::TextureConverter::Shutdown(); VertexLoaderManager::Shutdown(); - VertexShaderCache::Shutdown(); + OGL::VertexShaderCache::Shutdown(); VertexShaderManager::Shutdown(); PixelShaderManager::Shutdown(); - PixelShaderCache::Shutdown(); + OGL::PixelShaderCache::Shutdown(); delete g_vertex_manager; delete g_texture_cache; OpcodeDecoder_Shutdown();