From e5210de9d5da0cdbe5b8a8171b21d9ab9c5a8d5c Mon Sep 17 00:00:00 2001 From: Rodolfo Osvaldo Bogado Date: Fri, 10 Jun 2011 19:16:09 +0000 Subject: [PATCH] just a little cleanup to maintain minimal interfaces git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7591 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/VideoCommon/Src/PixelShaderGen.cpp | 4 ++-- Source/Core/VideoCommon/Src/PixelShaderGen.h | 2 +- .../Core/VideoCommon/Src/TextureConversionShader.cpp | 6 +++--- Source/Core/VideoCommon/Src/VertexShaderGen.cpp | 4 ++-- Source/Core/VideoCommon/Src/VideoCommon.h | 12 +++++++----- .../Plugins/Plugin_VideoDX9/Src/PixelShaderCache.cpp | 2 +- Source/Plugins/Plugin_VideoDX9/Src/main.cpp | 8 ++++---- 7 files changed, 20 insertions(+), 18 deletions(-) diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index f1a3eded7f..530ecd54bb 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -380,7 +380,7 @@ static void BuildSwapModeTable() } } -const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u32 components, bool hlsl_sm_2_0 ) +const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u32 components) { setlocale(LC_NUMERIC, "C"); // Reset locale for compilation text[sizeof(text) - 1] = 0x7C; // canary @@ -460,7 +460,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType WRITE(p, " out float4 ocol0 : COLOR0,%s%s\n in float4 rawpos : %s,\n", dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND ? "\n out float4 ocol1 : COLOR1," : "", DepthTextureEnable ? "\n out float depth : DEPTH," : "", - ApiType == API_OPENGL ? "WPOS" : hlsl_sm_2_0 ? "POSITION" : "VPOS"); + ApiType & API_OPENGL ? "WPOS" : ApiType & API_D3D9_SM20 ? "POSITION" : "VPOS"); } else { diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.h b/Source/Core/VideoCommon/Src/PixelShaderGen.h index ad6533b4e6..b495703a13 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.h +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.h @@ -113,7 +113,7 @@ enum DSTALPHA_MODE DSTALPHA_DUAL_SOURCE_BLEND // Use dual-source blending }; -const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u32 components, bool hlsl_sm_2_0 = false); +const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u32 components); void GetPixelShaderId(PIXELSHADERUID *uid, DSTALPHA_MODE dstAlphaMode); extern PIXELSHADERUID last_pixel_shader_uid; diff --git a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp index c24a11b180..c921a1a9fd 100644 --- a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp @@ -80,7 +80,7 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType) { WRITE(p,"uniform samplerRECT samp0 : register(s0);\n"); } - else if (ApiType == API_D3D9) + else if (ApiType & API_D3D9) { WRITE(p,"uniform sampler samp0 : register(s0);\n"); } @@ -150,7 +150,7 @@ void Write32BitSwizzler(char*& p, u32 format, API_TYPE ApiType) { WRITE(p,"uniform samplerRECT samp0 : register(s0);\n"); } - else if (ApiType == API_D3D9) + else if (ApiType & API_D3D9) { WRITE(p,"uniform sampler samp0 : register(s0);\n"); } @@ -209,7 +209,7 @@ void Write32BitSwizzler(char*& p, u32 format, API_TYPE ApiType) void WriteSampleColor(char*& p, const char* colorComp, const char* dest, API_TYPE ApiType) { const char* texSampleOpName; - if (ApiType == API_D3D9) + if (ApiType & API_D3D9) texSampleOpName = "tex2D"; else if (ApiType == API_D3D11) texSampleOpName = "tex0.Sample"; diff --git a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp index 8f858f71ce..747b95c0da 100644 --- a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp @@ -112,7 +112,7 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type) _assert_(bpmem.genMode.numtexgens == xfregs.numTexGen.numTexGens); _assert_(bpmem.genMode.numcolchans == xfregs.numChan.numColorChans); - bool is_d3d = (api_type == API_D3D9 || api_type == API_D3D11); + bool is_d3d = (api_type & API_D3D9 || api_type == API_D3D11); u32 lightMask = 0; if (xfregs.numChan.numColorChans > 0) lightMask |= xfregs.color[0].GetFullLightMask() | xfregs.alpha[0].GetFullLightMask(); @@ -187,7 +187,7 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type) // transforms if (components & VB_HAS_POSMTXIDX) { - if (api_type == API_D3D9) + if (api_type & API_D3D9) { WRITE(p, "int4 indices = D3DCOLORtoUBYTE4(blend_indices);\n"); WRITE(p, "int posmtx = indices.x;\n"); diff --git a/Source/Core/VideoCommon/Src/VideoCommon.h b/Source/Core/VideoCommon/Src/VideoCommon.h index b0e01012fd..030c1f0b32 100644 --- a/Source/Core/VideoCommon/Src/VideoCommon.h +++ b/Source/Core/VideoCommon/Src/VideoCommon.h @@ -107,11 +107,13 @@ struct TargetRectangle : public MathUtil::Rectangle typedef enum { - API_OPENGL, - API_D3D9, - API_D3D11, - API_GLSL, - API_NONE + API_OPENGL = 1, + API_D3D9_SM30 = 2, + API_D3D9_SM20 = 4, + API_D3D9 = 6, + API_D3D11 = 8, + API_GLSL = 16, + API_NONE = 32 } API_TYPE; inline u32 RGBA8ToRGBA6ToRGBA8(u32 src) diff --git a/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.cpp index 66ddbae768..1a7b61db0f 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.cpp @@ -360,7 +360,7 @@ bool PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 components) // Need to compile a new shader - const char *code = GeneratePixelShaderCode(dstAlphaMode, API_D3D9, components, ((D3D::GetCaps().PixelShaderVersion >> 8) & 0xFF) < 3); + const char *code = GeneratePixelShaderCode(dstAlphaMode, ((D3D::GetCaps().PixelShaderVersion >> 8) & 0xFF) < 3 ? API_D3D9_SM20 : API_D3D9_SM30, components); u32 code_hash = HashAdler32((const u8 *)code, strlen(code)); unique_shaders.insert(code_hash); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/main.cpp b/Source/Plugins/Plugin_VideoDX9/Src/main.cpp index c86b456be5..adb37f9f10 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/main.cpp @@ -89,15 +89,15 @@ std::string VideoBackend::GetName() void InitBackendInfo() { DX9::D3D::Init(); - - g_Config.backend_info.APIType = API_D3D9; + const int shaderModel = ((DX9::D3D::GetCaps().PixelShaderVersion >> 8) & 0xFF); + const int maxConstants = (shaderModel < 3) ? 32 : ((shaderModel < 4) ? 224 : 65536); + g_Config.backend_info.APIType = shaderModel < 3 ? API_D3D9_SM20 :API_D3D9_SM30; g_Config.backend_info.bUseRGBATextures = false; g_Config.backend_info.bSupports3DVision = true; g_Config.backend_info.bSupportsDualSourceBlend = false; g_Config.backend_info.bSupportsFormatReinterpretation = true; - const int shaderModel = ((DX9::D3D::GetCaps().PixelShaderVersion >> 8) & 0xFF); - const int maxConstants = (shaderModel < 3) ? 32 : ((shaderModel < 4) ? 224 : 65536); + g_Config.backend_info.bSupportsPixelLighting = C_PLIGHTS + 40 <= maxConstants && C_PMATERIALS + 4 <= maxConstants; // adapters