mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 00:59:44 -06:00
some fixes to my last commit and ....
modify shader generator to produce native sm 4.0 code. eliminate compatibility mode in dx11 so now all shader must work much better. please test. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5691 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -90,7 +90,7 @@ bool CompilePixelShader(const char* code, unsigned int len, ID3D10Blob** blob)
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
UINT flags = D3D10_SHADER_ENABLE_BACKWARDS_COMPATIBILITY|D3D10_SHADER_DEBUG|D3D10_SHADER_WARNINGS_ARE_ERRORS;
|
||||
#else
|
||||
UINT flags = D3D10_SHADER_ENABLE_BACKWARDS_COMPATIBILITY|D3D10_SHADER_OPTIMIZATION_LEVEL3|D3D10_SHADER_SKIP_VALIDATION;
|
||||
UINT flags = D3D10_SHADER_OPTIMIZATION_LEVEL3;
|
||||
#endif
|
||||
HRESULT hr = D3DCompile(code, len, NULL, NULL, NULL, "main", D3D::PixelShaderVersionString(),
|
||||
flags, 0, &shaderBuffer, &errorBuffer);
|
||||
|
@ -47,43 +47,46 @@ ID3D11PixelShader* s_ClearProgram = NULL;
|
||||
|
||||
const char clear_program_code[] = {
|
||||
"void main(\n"
|
||||
"out float4 ocol0 : COLOR0,\n"
|
||||
"in float4 pos : POSITION,\n"
|
||||
"out float4 ocol0 : SV_Target,\n"
|
||||
"in float4 pos : SV_Position,\n"
|
||||
"in float4 incol0 : COLOR0){\n"
|
||||
"ocol0 = incol0;\n"
|
||||
"}\n"
|
||||
};
|
||||
|
||||
const char color_copy_program_code[] = {
|
||||
"uniform sampler samp0 : register(s0);\n"
|
||||
"sampler samp0 : register(s0);\n"
|
||||
"Texture2D Tex0 : register(t0);\n"
|
||||
"void main(\n"
|
||||
"out float4 ocol0 : COLOR0,\n"
|
||||
"in float4 pos : POSITION,\n"
|
||||
"out float4 ocol0 : SV_Target,\n"
|
||||
"in float4 pos : SV_Position,\n"
|
||||
"in float2 uv0 : TEXCOORD0){\n"
|
||||
"ocol0 = tex2D(samp0,uv0);\n"
|
||||
"ocol0 = Tex0.Sample(samp0,uv0);\n"
|
||||
"}\n"
|
||||
};
|
||||
|
||||
const char color_matrix_program_code[] = {
|
||||
"uniform sampler samp0 : register(s0);\n"
|
||||
"sampler samp0 : register(s0);\n"
|
||||
"Texture2D Tex0 : register(t0);\n"
|
||||
"uniform float4 cColMatrix[5] : register(c0);\n"
|
||||
"void main(\n"
|
||||
"out float4 ocol0 : COLOR0,\n"
|
||||
"in float4 pos : POSITION,\n"
|
||||
"out float4 ocol0 : SV_Target,\n"
|
||||
"in float4 pos : SV_Position,\n"
|
||||
" in float2 uv0 : TEXCOORD0){\n"
|
||||
"float4 texcol = tex2D(samp0,uv0);\n"
|
||||
"float4 texcol = Tex0.Sample(samp0,uv0);\n"
|
||||
"ocol0 = float4(dot(texcol,cColMatrix[0]),dot(texcol,cColMatrix[1]),dot(texcol,cColMatrix[2]),dot(texcol,cColMatrix[3])) + cColMatrix[4];\n"
|
||||
"}\n"
|
||||
};
|
||||
|
||||
const char depth_matrix_program[] = {
|
||||
"uniform sampler samp0 : register(s0);\n"
|
||||
"sampler samp0 : register(s0);\n"
|
||||
"Texture2D Tex0 : register(t0);\n"
|
||||
"uniform float4 cColMatrix[5] : register(c0);\n"
|
||||
"void main(\n"
|
||||
"out float4 ocol0 : COLOR0,\n"
|
||||
" in float4 pos : POSITION,\n"
|
||||
"out float4 ocol0 : SV_Target,\n"
|
||||
" in float4 pos : SV_Position,\n"
|
||||
" in float2 uv0 : TEXCOORD0){\n"
|
||||
"float4 texcol = tex2D(samp0,uv0);\n"
|
||||
"float4 texcol = Tex0.Sample(samp0,uv0);\n"
|
||||
"float4 EncodedDepth = frac((texcol.r * (16777215.0f/16777216.0f)) * float4(1.0f,255.0f,255.0f*255.0f,255.0f*255.0f*255.0f));\n"
|
||||
"texcol = float4((EncodedDepth.rgb * (16777216.0f/16777215.0f)),1.0f);\n"
|
||||
"ocol0 = float4(dot(texcol,cColMatrix[0]),dot(texcol,cColMatrix[1]),dot(texcol,cColMatrix[2]),dot(texcol,cColMatrix[3])) + cColMatrix[4];\n"
|
||||
@ -125,23 +128,35 @@ unsigned int ps_constant_offset_table[] = {
|
||||
};
|
||||
void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
|
||||
{
|
||||
D3D::gfxstate->psconstants[ps_constant_offset_table[const_number] ] = f1;
|
||||
D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]+1] = f2;
|
||||
D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]+2] = f3;
|
||||
D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]+3] = f4;
|
||||
D3D::gfxstate->pscbufchanged = true;
|
||||
if(D3D::gfxstate->psconstants[ps_constant_offset_table[const_number] ] != f1
|
||||
|| D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]+1] != f2
|
||||
|| D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]+2] != f3
|
||||
|| D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]+3] != f4)
|
||||
{
|
||||
D3D::gfxstate->psconstants[ps_constant_offset_table[const_number] ] = f1;
|
||||
D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]+1] = f2;
|
||||
D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]+2] = f3;
|
||||
D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]+3] = f4;
|
||||
D3D::gfxstate->pscbufchanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
void SetPSConstant4fv(unsigned int const_number, const float* f)
|
||||
{
|
||||
memcpy(&D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]], f, sizeof(float)*4);
|
||||
D3D::gfxstate->pscbufchanged = true;
|
||||
if(memcmp(&D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]], f, sizeof(float)*4))
|
||||
{
|
||||
memcpy(&D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]], f, sizeof(float)*4);
|
||||
D3D::gfxstate->pscbufchanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float* f)
|
||||
{
|
||||
memcpy(&D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]], f, sizeof(float)*4*count);
|
||||
D3D::gfxstate->pscbufchanged = true;
|
||||
if(memcmp(&D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]], f, sizeof(float)*4*count))
|
||||
{
|
||||
memcpy(&D3D::gfxstate->psconstants[ps_constant_offset_table[const_number]], f, sizeof(float)*4*count);
|
||||
D3D::gfxstate->pscbufchanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
// this class will load the precompiled shaders into our cache
|
||||
|
@ -51,17 +51,26 @@ ID3D11InputLayout* VertexShaderCache::GetClearInputLayout() { return ClearLayout
|
||||
unsigned int vs_constant_offset_table[238];
|
||||
void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
|
||||
{
|
||||
D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number] ] = f1;
|
||||
D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]+1] = f2;
|
||||
D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]+2] = f3;
|
||||
D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]+3] = f4;
|
||||
D3D::gfxstate->vscbufchanged = true;
|
||||
if(D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number] ] != f1
|
||||
|| D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]+1] != f2
|
||||
|| D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]+2] != f3
|
||||
|| D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]+3] != f4)
|
||||
{
|
||||
D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number] ] = f1;
|
||||
D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]+1] = f2;
|
||||
D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]+2] = f3;
|
||||
D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]+3] = f4;
|
||||
D3D::gfxstate->vscbufchanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
void SetVSConstant4fv(unsigned int const_number, const float* f)
|
||||
{
|
||||
memcpy(&D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]], f, sizeof(float)*4);
|
||||
D3D::gfxstate->vscbufchanged = true;
|
||||
if(memcmp(&D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]], f, sizeof(float)*4))
|
||||
{
|
||||
memcpy(&D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]], f, sizeof(float)*4);
|
||||
D3D::gfxstate->vscbufchanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float* f)
|
||||
@ -69,14 +78,18 @@ void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const
|
||||
for (unsigned int i = 0; i < count; i++)
|
||||
{
|
||||
memcpy(&D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number+i]], f+3*i, sizeof(float)*3);
|
||||
D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number+i]+3] = 0.f;
|
||||
D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number+i]+3] = 0.f;
|
||||
}
|
||||
D3D::gfxstate->vscbufchanged = true;
|
||||
}
|
||||
|
||||
void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float* f)
|
||||
{
|
||||
memcpy(&D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]], f, sizeof(float)*4*count);
|
||||
D3D::gfxstate->vscbufchanged = true;
|
||||
if(memcmp(&D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]], f, sizeof(float)*4*count))
|
||||
{
|
||||
memcpy(&D3D::gfxstate->vsconstants[vs_constant_offset_table[const_number]], f, sizeof(float)*4*count);
|
||||
D3D::gfxstate->vscbufchanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
// this class will load the precompiled shaders into our cache
|
||||
|
Reference in New Issue
Block a user