mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-13 00:58:29 +02:00
normalize the efb to texture process for color textures to make it work the same in all the plugins and with the same accuracy as real hardware (almost :))
please test for regressions and fixes. some little changes to make pixel shader more dx9 sm2.0 friendly. the condition is not to use pixel lighting ( sorry no hardware support for the quantity of parameters needed). git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6777 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -96,17 +96,22 @@ void PixelShaderCache::Init()
|
||||
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB, (GLint *)&maxattribs);
|
||||
INFO_LOG(VIDEO, "pixel max_alu=%d, max_inst=%d, max_attrib=%d", s_nMaxPixelInstructions, maxinst, maxattribs);
|
||||
|
||||
char pmatrixprog[1024];
|
||||
char pmatrixprog[2048];
|
||||
sprintf(pmatrixprog, "!!ARBfp1.0"
|
||||
"TEMP R0;\n"
|
||||
"TEMP R1;\n"
|
||||
"PARAM K0 = { 0.5, 0.5, 0.5, 0.5};\n"
|
||||
"TEX R0, fragment.texcoord[0], texture[0], RECT;\n"
|
||||
"DP4 R1.w, R0, program.env[%d];\n"
|
||||
"DP4 R1.z, R0, program.env[%d];\n"
|
||||
"MUL R0, R0, program.env[%d];\n"
|
||||
"ADD R0, R0, K0;\n"
|
||||
"FLR R0, R0;\n"
|
||||
"MUL R0, R0, program.env[%d];\n"
|
||||
"DP4 R1.x, R0, program.env[%d];\n"
|
||||
"DP4 R1.y, R0, program.env[%d];\n"
|
||||
"DP4 R1.z, R0, program.env[%d];\n"
|
||||
"DP4 R1.w, R0, program.env[%d];\n"
|
||||
"ADD result.color, R1, program.env[%d];\n"
|
||||
"END\n", C_COLORMATRIX+3, C_COLORMATRIX+2, C_COLORMATRIX, C_COLORMATRIX+1, C_COLORMATRIX+4);
|
||||
"END\n",C_COLORMATRIX+5,C_COLORMATRIX+6, C_COLORMATRIX, C_COLORMATRIX+1, C_COLORMATRIX+2, C_COLORMATRIX+3, C_COLORMATRIX+4);
|
||||
glGenProgramsARB(1, &s_ColorMatrixProgram);
|
||||
SetCurrentShader(s_ColorMatrixProgram);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei)strlen(pmatrixprog), pmatrixprog);
|
||||
@ -118,12 +123,13 @@ void PixelShaderCache::Init()
|
||||
s_ColorMatrixProgram = 0;
|
||||
}
|
||||
|
||||
sprintf(pmatrixprog, "!!ARBfp1.0\n"
|
||||
sprintf(pmatrixprog, "!!ARBfp1.0\n"
|
||||
"TEMP R0;\n"
|
||||
"TEMP R1;\n"
|
||||
"TEMP R2;\n"
|
||||
//16777215/16777216*256, 1/255, 256, 0
|
||||
"PARAM K0 = { 255.99998474121, 0.003921568627451, 256.0, 0.0};\n"
|
||||
"PARAM K0 = { 255.99998474121, 0.003921568627451, 256.0, 0.0};\n"
|
||||
"PARAM K1 = { 15.0, 0.066666666666, 0.0, 0.0};\n"
|
||||
//sample the depth value
|
||||
"TEX R2, fragment.texcoord[0], texture[0], RECT;\n"
|
||||
|
||||
@ -138,21 +144,23 @@ void PixelShaderCache::Init()
|
||||
//gives {?, 128/255, 254/255, ?} for depth value 254/255
|
||||
//on some gpus
|
||||
|
||||
"FLR R0.z,R0;\n" //bits 31..24
|
||||
"FLR R0.x,R0;\n" //bits 31..24
|
||||
|
||||
"SUB R0.xyw,R0,R0.z;\n" //subtract bits 31..24 from rest
|
||||
"MUL R0.xyw,R0,K0.z;\n" // *256
|
||||
"SUB R0.yzw,R0,R0.x;\n" //subtract bits 31..24 from rest
|
||||
"MUL R0.yzw,R0,K0.z;\n" // *256
|
||||
"FLR R0.y,R0;\n" //bits 23..16
|
||||
|
||||
"SUB R0.xw,R0,R0.y;\n" //subtract bits 23..16 from rest
|
||||
"MUL R0.xw,R0,K0.z;\n" // *256
|
||||
"FLR R0.x,R0;\n" //bits 15..8
|
||||
"SUB R0.zw,R0,R0.y;\n" //subtract bits 23..16 from rest
|
||||
"MUL R0.zw,R0,K0.z;\n" // *256
|
||||
"FLR R0.z,R0;\n" //bits 15..8
|
||||
|
||||
"SUB R0.w,R0,R0.x;\n" //subtract bits 15..8 from rest
|
||||
"MUL R0.w,R0,K0.z;\n" // *256
|
||||
"FLR R0.w,R0;\n" //bits 7..0
|
||||
"MOV R0.w,R0.x;\n" //duplicate bit 31..24
|
||||
|
||||
"MUL R0,R0,K0.y;\n" // /255
|
||||
|
||||
"MUL R0,R0,K0.y;\n" // /255
|
||||
"MUL R0.w,R0,K1.x;\n" // *15
|
||||
"FLR R0.w,R0;\n" //bits 31..28
|
||||
"MUL R0.w,R0,K1.y;\n" // /15
|
||||
|
||||
"DP4 R1.x, R0, program.env[%d];\n"
|
||||
"DP4 R1.y, R0, program.env[%d];\n"
|
||||
@ -168,7 +176,7 @@ void PixelShaderCache::Init()
|
||||
if (err != GL_NO_ERROR) {
|
||||
ERROR_LOG(VIDEO, "Failed to create depth matrix fragment program");
|
||||
glDeleteProgramsARB(1, &s_DepthMatrixProgram);
|
||||
s_DepthMatrixProgram = 0;
|
||||
s_DepthMatrixProgram = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user