Allows DX9 shaders to be SM2 compatible again at the loss of accuracy. SM3 is recommended. Fixes issue 4546.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7585 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Sonicadvance1 2011-06-04 19:56:18 +00:00
parent 0e6bb4de35
commit db0c2bca5b
3 changed files with 96 additions and 96 deletions

View File

@ -380,7 +380,7 @@ static void BuildSwapModeTable()
}
}
const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u32 components)
const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u32 components, bool hlsl_sm_2_0 )
{
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" : "VPOS");
ApiType == API_OPENGL ? "WPOS" : hlsl_sm_2_0 ? "POSITION" : "VPOS");
}
else
{

View File

@ -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);
const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType, u32 components, bool hlsl_sm_2_0 = false);
void GetPixelShaderId(PIXELSHADERUID *uid, DSTALPHA_MODE dstAlphaMode);
extern PIXELSHADERUID last_pixel_shader_uid;

View File

@ -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);
const char *code = GeneratePixelShaderCode(dstAlphaMode, API_D3D9, components, ((D3D::caps.PixelShaderVersion >> 8) & 0xFF) < 3);
u32 code_hash = HashAdler32((const u8 *)code, strlen(code));
unique_shaders.insert(code_hash);