From 146e435009eec015a160e35d13cad4f22d7a8d69 Mon Sep 17 00:00:00 2001 From: degasus Date: Mon, 25 Nov 2013 08:56:01 +0100 Subject: OpenGL: fix efb2ram for texture2D This was hacky as hell. Our efb2ram shader generator is just freaked out. --- Source/Core/VideoCommon/Src/TextureConversionShader.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Source/Core/VideoCommon/Src/TextureConversionShader.cpp') diff --git a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp index 99e9f702c7..022d18b427 100644 --- a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp @@ -81,7 +81,7 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType) if (ApiType == API_OPENGL) { WRITE(p, "#define samp0 samp9\n"); - WRITE(p, "uniform sampler2DRect samp0;\n"); + WRITE(p, "uniform sampler2D samp0;\n"); WRITE(p, " out vec4 ocol0;\n"); WRITE(p, " VARYIN float2 uv0;\n"); @@ -146,7 +146,7 @@ void Write32BitSwizzler(char*& p, u32 format, API_TYPE ApiType) if (ApiType == API_OPENGL) { WRITE(p, "#define samp0 samp9\n"); - WRITE(p, "uniform sampler2DRect samp0;\n"); + WRITE(p, "uniform sampler2D samp0;\n"); WRITE(p, " out float4 ocol0;\n"); WRITE(p, " VARYIN float2 uv0;\n"); @@ -202,7 +202,7 @@ void WriteSampleColor(char*& p, const char* colorComp, const char* dest, API_TYP if (ApiType == API_D3D) texSampleOpName = "tex0.Sample"; else // OGL - texSampleOpName = "texture2DRect"; + texSampleOpName = "texture"; // the increment of sampleUv.x is delayed, so we perform it here. see WriteIncrementSampleX. const char* texSampleIncrementUnit; @@ -211,7 +211,7 @@ void WriteSampleColor(char*& p, const char* colorComp, const char* dest, API_TYP else // OGL texSampleIncrementUnit = I_COLORS"[0].x"; - WRITE(p, " %s = %s(samp0, sampleUv + float2(%d.0 * (%s), 0.0)).%s;\n", + WRITE(p, " %s = %s(samp0, (sampleUv + float2(%d.0 * (%s), 0.0)) / textureSize(samp0, 0)).%s;\n", dest, texSampleOpName, s_incrementSampleXCount, texSampleIncrementUnit, colorComp); } -- cgit v1.2.3 From a289e0604f3fd3663a7d32e8aafbe9d8286b35ad Mon Sep 17 00:00:00 2001 From: degasus Date: Mon, 25 Nov 2013 14:53:44 +0100 Subject: TextureConverter: remove D3D9 foo This file is in VideoCommon, but as D3D11 doesn't use it and D3D9 is dropped, it's time to clean up. --- .../VideoCommon/Src/TextureConversionShader.cpp | 49 ++++------------------ 1 file changed, 8 insertions(+), 41 deletions(-) (limited to 'Source/Core/VideoCommon/Src/TextureConversionShader.cpp') diff --git a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp index 022d18b427..c78b854535 100644 --- a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp @@ -57,15 +57,6 @@ u16 GetEncodedSampleCount(u32 format) } } -const char* WriteRegister(API_TYPE ApiType, const char *prefix, const u32 num) -{ - if (ApiType == API_OPENGL) - return ""; // Once we switch to GLSL 1.3 we can do something here - static char result[64]; - sprintf(result, " : register(%s%d)", prefix, num); - return result; -} - // block dimensions : widthStride, heightStride // texture dims : width, height, x offset, y offset void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType) @@ -73,7 +64,7 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType) // [0] left, top, right, bottom of source rectangle within source texture // [1] width and height of destination texture in pixels // Two were merged for GLSL - WRITE(p, "uniform float4 " I_COLORS"[2] %s;\n", WriteRegister(ApiType, "c", C_COLORS)); + WRITE(p, "uniform float4 " I_COLORS"[2];\n"); int blkW = TexDecoder_GetBlockWidthInTexels(format); int blkH = TexDecoder_GetBlockHeightInTexels(format); @@ -118,16 +109,9 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType) WRITE(p, " sampleUv = sampleUv * " I_COLORS"[0].xy;\n"); - if (ApiType == API_OPENGL) - WRITE(p," sampleUv.y = " I_COLORS"[1].y - sampleUv.y;\n"); + WRITE(p," sampleUv.y = " I_COLORS"[1].y - sampleUv.y;\n"); WRITE(p, " sampleUv = sampleUv + " I_COLORS"[1].zw;\n"); - - if (ApiType != API_OPENGL) - { - WRITE(p, " sampleUv = sampleUv + float2(0.0,1.0);\n"); // still need to determine the reason for this - WRITE(p, " sampleUv = sampleUv / " I_COLORS"[0].zw;\n"); - } } // block dimensions : widthStride, heightStride @@ -137,7 +121,7 @@ void Write32BitSwizzler(char*& p, u32 format, API_TYPE ApiType) // [0] left, top, right, bottom of source rectangle within source texture // [1] width and height of destination texture in pixels // Two were merged for GLSL - WRITE(p, "uniform float4 " I_COLORS"[2] %s;\n", WriteRegister(ApiType, "c", C_COLORS)); + WRITE(p, "uniform float4 " I_COLORS"[2];\n"); int blkW = TexDecoder_GetBlockWidthInTexels(format); int blkH = TexDecoder_GetBlockHeightInTexels(format); @@ -184,35 +168,18 @@ void Write32BitSwizzler(char*& p, u32 format, API_TYPE ApiType) WRITE(p, " sampleUv.y = yb + xoff;\n"); WRITE(p, " sampleUv = sampleUv * " I_COLORS"[0].xy;\n"); - if (ApiType == API_OPENGL) - WRITE(p," sampleUv.y = " I_COLORS"[1].y - sampleUv.y;\n"); + WRITE(p," sampleUv.y = " I_COLORS"[1].y - sampleUv.y;\n"); WRITE(p, " sampleUv = sampleUv + " I_COLORS"[1].zw;\n"); - - if (ApiType != API_OPENGL) - { - WRITE(p, " sampleUv = sampleUv + float2(0.0,1.0);\n");// still to determine the reason for this - WRITE(p, " sampleUv = sampleUv / " I_COLORS"[0].zw;\n"); - } } void WriteSampleColor(char*& p, const char* colorComp, const char* dest, API_TYPE ApiType) { - const char* texSampleOpName; - if (ApiType == API_D3D) - texSampleOpName = "tex0.Sample"; - else // OGL - texSampleOpName = "texture"; - // the increment of sampleUv.x is delayed, so we perform it here. see WriteIncrementSampleX. - const char* texSampleIncrementUnit; - if (ApiType == API_D3D) - texSampleIncrementUnit = I_COLORS"[0].x / " I_COLORS"[0].z"; - else // OGL - texSampleIncrementUnit = I_COLORS"[0].x"; - - WRITE(p, " %s = %s(samp0, (sampleUv + float2(%d.0 * (%s), 0.0)) / textureSize(samp0, 0)).%s;\n", - dest, texSampleOpName, s_incrementSampleXCount, texSampleIncrementUnit, colorComp); + const char* texSampleIncrementUnit = I_COLORS"[0].x"; + + WRITE(p, " %s = texture(samp0, (sampleUv + float2(%d.0 * (%s), 0.0)) / textureSize(samp0, 0)).%s;\n", + dest, s_incrementSampleXCount, texSampleIncrementUnit, colorComp); } void WriteColorToIntensity(char*& p, const char* src, const char* dest) -- cgit v1.2.3 From bcb31b09d38463f8a7a515858a2143477bfc8935 Mon Sep 17 00:00:00 2001 From: degasus Date: Mon, 25 Nov 2013 15:01:18 +0100 Subject: TextureConverter: Use gl_FragCoord instead of uv0 --- Source/Core/VideoCommon/Src/TextureConversionShader.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'Source/Core/VideoCommon/Src/TextureConversionShader.cpp') diff --git a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp index c78b854535..a6f63ad6ee 100644 --- a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp @@ -75,7 +75,6 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType) WRITE(p, "uniform sampler2D samp0;\n"); WRITE(p, " out vec4 ocol0;\n"); - WRITE(p, " VARYIN float2 uv0;\n"); WRITE(p, "void main()\n"); } else // D3D @@ -84,13 +83,12 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType) WRITE(p, "Texture2D Tex0 : register(t0);\n"); WRITE(p,"void main(\n"); - WRITE(p," out float4 ocol0 : SV_Target,\n"); - WRITE(p," in float2 uv0 : TEXCOORD0)\n"); + WRITE(p," out float4 ocol0 : SV_Target)\n"); } WRITE(p, "{\n" " float2 sampleUv;\n" - " float2 uv1 = floor(uv0);\n"); + " float2 uv1 = floor(gl_FragCoord.xy);\n"); WRITE(p, " uv1.x = uv1.x * %d.0;\n", samples); @@ -133,7 +131,6 @@ void Write32BitSwizzler(char*& p, u32 format, API_TYPE ApiType) WRITE(p, "uniform sampler2D samp0;\n"); WRITE(p, " out float4 ocol0;\n"); - WRITE(p, " VARYIN float2 uv0;\n"); WRITE(p, "void main()\n"); } else @@ -142,14 +139,13 @@ void Write32BitSwizzler(char*& p, u32 format, API_TYPE ApiType) WRITE(p, "Texture2D Tex0 : register(t0);\n"); WRITE(p,"void main(\n"); - WRITE(p," out float4 ocol0 : SV_Target,\n"); - WRITE(p," in float2 uv0 : TEXCOORD0)\n"); + WRITE(p," out float4 ocol0 : SV_Target)\n"); } WRITE(p, "{\n" " float2 sampleUv;\n" - " float2 uv1 = floor(uv0);\n"); + " float2 uv1 = floor(gl_FragCoord.xy);\n"); WRITE(p, " float yl = floor(uv1.y / %d.0);\n", blkH); WRITE(p, " float yb = yl * %d.0;\n", blkH); -- cgit v1.2.3 From 6750a81972822099980a59f334b7928e5ac92be7 Mon Sep 17 00:00:00 2001 From: degasus Date: Mon, 25 Nov 2013 15:49:13 +0100 Subject: TextureConverter: Use integer math for swizzling also move int(efb_coord) -> float(ogl_fb_coord) into WriteSampleColor --- .../VideoCommon/Src/TextureConversionShader.cpp | 98 +++++++++++----------- 1 file changed, 47 insertions(+), 51 deletions(-) (limited to 'Source/Core/VideoCommon/Src/TextureConversionShader.cpp') diff --git a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp index a6f63ad6ee..573b35383a 100644 --- a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp @@ -64,7 +64,7 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType) // [0] left, top, right, bottom of source rectangle within source texture // [1] width and height of destination texture in pixels // Two were merged for GLSL - WRITE(p, "uniform float4 " I_COLORS"[2];\n"); + WRITE(p, "uniform float4 " I_COLORS";\n"); int blkW = TexDecoder_GetBlockWidthInTexels(format); int blkH = TexDecoder_GetBlockHeightInTexels(format); @@ -87,29 +87,23 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType) } WRITE(p, "{\n" - " float2 sampleUv;\n" - " float2 uv1 = floor(gl_FragCoord.xy);\n"); - - WRITE(p, " uv1.x = uv1.x * %d.0;\n", samples); - - WRITE(p, " float xl = floor(uv1.x / %d.0);\n", blkW); - WRITE(p, " float xib = uv1.x - (xl * %d.0);\n", blkW); - WRITE(p, " float yl = floor(uv1.y / %d.0);\n", blkH); - WRITE(p, " float yb = yl * %d.0;\n", blkH); - WRITE(p, " float yoff = uv1.y - yb;\n"); - WRITE(p, " float xp = uv1.x + (yoff * " I_COLORS"[1].x);\n"); - WRITE(p, " float xel = floor(xp / %d.0);\n", blkW); - WRITE(p, " float xb = floor(xel / %d.0);\n", blkH); - WRITE(p, " float xoff = xel - (xb * %d.0);\n", blkH); - - WRITE(p, " sampleUv.x = xib + (xb * %d.0);\n", blkW); + " int2 sampleUv;\n" + " int2 uv1 = int2(gl_FragCoord.xy);\n"); + + WRITE(p, " uv1.x = uv1.x * %d;\n", samples); + + WRITE(p, " int xl = uv1.x / %d;\n", blkW); + WRITE(p, " int xib = uv1.x - xl * %d;\n", blkW); + WRITE(p, " int yl = uv1.y / %d;\n", blkH); + WRITE(p, " int yb = yl * %d;\n", blkH); + WRITE(p, " int yoff = uv1.y - yb;\n"); + WRITE(p, " int xp = uv1.x + yoff * int(" I_COLORS".z);\n"); + WRITE(p, " int xel = xp / %d;\n", blkW); + WRITE(p, " int xb = xel / %d;\n", blkH); + WRITE(p, " int xoff = xel - xb * %d;\n", blkH); + + WRITE(p, " sampleUv.x = xib + xb * %d;\n", blkW); WRITE(p, " sampleUv.y = yb + xoff;\n"); - - WRITE(p, " sampleUv = sampleUv * " I_COLORS"[0].xy;\n"); - - WRITE(p," sampleUv.y = " I_COLORS"[1].y - sampleUv.y;\n"); - - WRITE(p, " sampleUv = sampleUv + " I_COLORS"[1].zw;\n"); } // block dimensions : widthStride, heightStride @@ -119,7 +113,7 @@ void Write32BitSwizzler(char*& p, u32 format, API_TYPE ApiType) // [0] left, top, right, bottom of source rectangle within source texture // [1] width and height of destination texture in pixels // Two were merged for GLSL - WRITE(p, "uniform float4 " I_COLORS"[2];\n"); + WRITE(p, "uniform float4 " I_COLORS";\n"); int blkW = TexDecoder_GetBlockWidthInTexels(format); int blkH = TexDecoder_GetBlockHeightInTexels(format); @@ -144,38 +138,40 @@ void Write32BitSwizzler(char*& p, u32 format, API_TYPE ApiType) WRITE(p, "{\n" - " float2 sampleUv;\n" - " float2 uv1 = floor(gl_FragCoord.xy);\n"); - - WRITE(p, " float yl = floor(uv1.y / %d.0);\n", blkH); - WRITE(p, " float yb = yl * %d.0;\n", blkH); - WRITE(p, " float yoff = uv1.y - yb;\n"); - WRITE(p, " float xp = uv1.x + (yoff * " I_COLORS"[1].x);\n"); - WRITE(p, " float xel = floor(xp / 2.0);\n"); - WRITE(p, " float xb = floor(xel / %d.0);\n", blkH); - WRITE(p, " float xoff = xel - (xb * %d.0);\n", blkH); - - WRITE(p, " float x2 = uv1.x * 2.0;\n"); - WRITE(p, " float xl = floor(x2 / %d.0);\n", blkW); - WRITE(p, " float xib = x2 - (xl * %d.0);\n", blkW); - WRITE(p, " float halfxb = floor(xb / 2.0);\n"); - - WRITE(p, " sampleUv.x = xib + (halfxb * %d.0);\n", blkW); + " int2 sampleUv;\n" + " int2 uv1 = int2(gl_FragCoord.xy);\n"); + + WRITE(p, " int yl = uv1.y / %d;\n", blkH); + WRITE(p, " int yb = yl * %d;\n", blkH); + WRITE(p, " int yoff = uv1.y - yb;\n"); + WRITE(p, " int xp = uv1.x + yoff * int(" I_COLORS".z);\n"); + WRITE(p, " int xel = xp / 2;\n"); + WRITE(p, " int xb = xel / %d;\n", blkH); + WRITE(p, " int xoff = xel - xb * %d;\n", blkH); + + WRITE(p, " int x2 = uv1.x * 2;\n"); + WRITE(p, " int xl = x2 / %d;\n", blkW); + WRITE(p, " int xib = x2 - xl * %d;\n", blkW); + WRITE(p, " int halfxb = xb / 2;\n"); + + WRITE(p, " sampleUv.x = xib + halfxb * %d;\n", blkW); WRITE(p, " sampleUv.y = yb + xoff;\n"); - WRITE(p, " sampleUv = sampleUv * " I_COLORS"[0].xy;\n"); - - WRITE(p," sampleUv.y = " I_COLORS"[1].y - sampleUv.y;\n"); - - WRITE(p, " sampleUv = sampleUv + " I_COLORS"[1].zw;\n"); } void WriteSampleColor(char*& p, const char* colorComp, const char* dest, API_TYPE ApiType) { - // the increment of sampleUv.x is delayed, so we perform it here. see WriteIncrementSampleX. - const char* texSampleIncrementUnit = I_COLORS"[0].x"; - - WRITE(p, " %s = texture(samp0, (sampleUv + float2(%d.0 * (%s), 0.0)) / textureSize(samp0, 0)).%s;\n", - dest, s_incrementSampleXCount, texSampleIncrementUnit, colorComp); + WRITE(p, + "{\n" + "float2 uv = sampleUv + int2(%d,0);\n" // pixel offset + "uv *= " I_COLORS".w;\n" // scale by two (if wanted) + "uv += " I_COLORS".xy;\n" // move to copyed rect + "uv += float2(0.5, 0.5);\n" // move center of pixel + "uv /= float2(%d, %d);\n" // normlize to [0:1] + "uv.y = 1-uv.y;\n" // ogl foo (disable this line for d3d) + "%s = texture(samp0, uv).%s;\n" + "}\n", + s_incrementSampleXCount, EFB_WIDTH, EFB_HEIGHT, dest, colorComp + ); } void WriteColorToIntensity(char*& p, const char* src, const char* dest) -- cgit v1.2.3 From 2a2f2fd4ebd29fec3de1498946d3374598d8fb6a Mon Sep 17 00:00:00 2001 From: degasus Date: Mon, 25 Nov 2013 16:19:08 +0100 Subject: TextureConvertion: merge Write*Swizzler --- .../VideoCommon/Src/TextureConversionShader.cpp | 84 +++++----------------- 1 file changed, 17 insertions(+), 67 deletions(-) (limited to 'Source/Core/VideoCommon/Src/TextureConversionShader.cpp') diff --git a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp index 573b35383a..bf625223dd 100644 --- a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp @@ -61,14 +61,15 @@ u16 GetEncodedSampleCount(u32 format) // texture dims : width, height, x offset, y offset void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType) { - // [0] left, top, right, bottom of source rectangle within source texture - // [1] width and height of destination texture in pixels - // Two were merged for GLSL + // left, top, of source rectangle within source texture + // width of the destination rectangle, scale_factor (1 or 2) WRITE(p, "uniform float4 " I_COLORS";\n"); int blkW = TexDecoder_GetBlockWidthInTexels(format); int blkH = TexDecoder_GetBlockHeightInTexels(format); int samples = GetEncodedSampleCount(format); + // 32 bit textures (RGBA8 and Z24) are store in 2 cache line increments + int factor = samples == 1 ? 2 : 1; if (ApiType == API_OPENGL) { WRITE(p, "#define samp0 samp9\n"); @@ -92,67 +93,16 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType) WRITE(p, " uv1.x = uv1.x * %d;\n", samples); - WRITE(p, " int xl = uv1.x / %d;\n", blkW); - WRITE(p, " int xib = uv1.x - xl * %d;\n", blkW); WRITE(p, " int yl = uv1.y / %d;\n", blkH); WRITE(p, " int yb = yl * %d;\n", blkH); WRITE(p, " int yoff = uv1.y - yb;\n"); WRITE(p, " int xp = uv1.x + yoff * int(" I_COLORS".z);\n"); - WRITE(p, " int xel = xp / %d;\n", blkW); + WRITE(p, " int xel = xp / %d;\n", samples == 1 ? factor : blkW); WRITE(p, " int xb = xel / %d;\n", blkH); WRITE(p, " int xoff = xel - xb * %d;\n", blkH); - - WRITE(p, " sampleUv.x = xib + xb * %d;\n", blkW); - WRITE(p, " sampleUv.y = yb + xoff;\n"); -} - -// block dimensions : widthStride, heightStride -// texture dims : width, height, x offset, y offset -void Write32BitSwizzler(char*& p, u32 format, API_TYPE ApiType) -{ - // [0] left, top, right, bottom of source rectangle within source texture - // [1] width and height of destination texture in pixels - // Two were merged for GLSL - WRITE(p, "uniform float4 " I_COLORS";\n"); - - int blkW = TexDecoder_GetBlockWidthInTexels(format); - int blkH = TexDecoder_GetBlockHeightInTexels(format); - - // 32 bit textures (RGBA8 and Z24) are store in 2 cache line increments - if (ApiType == API_OPENGL) - { - WRITE(p, "#define samp0 samp9\n"); - WRITE(p, "uniform sampler2D samp0;\n"); - - WRITE(p, " out float4 ocol0;\n"); - WRITE(p, "void main()\n"); - } - else - { - WRITE(p,"sampler samp0 : register(s0);\n"); - WRITE(p, "Texture2D Tex0 : register(t0);\n"); - - WRITE(p,"void main(\n"); - WRITE(p," out float4 ocol0 : SV_Target)\n"); - } - - - WRITE(p, "{\n" - " int2 sampleUv;\n" - " int2 uv1 = int2(gl_FragCoord.xy);\n"); - - WRITE(p, " int yl = uv1.y / %d;\n", blkH); - WRITE(p, " int yb = yl * %d;\n", blkH); - WRITE(p, " int yoff = uv1.y - yb;\n"); - WRITE(p, " int xp = uv1.x + yoff * int(" I_COLORS".z);\n"); - WRITE(p, " int xel = xp / 2;\n"); - WRITE(p, " int xb = xel / %d;\n", blkH); - WRITE(p, " int xoff = xel - xb * %d;\n", blkH); - - WRITE(p, " int x2 = uv1.x * 2;\n"); - WRITE(p, " int xl = x2 / %d;\n", blkW); - WRITE(p, " int xib = x2 - xl * %d;\n", blkW); - WRITE(p, " int halfxb = xb / 2;\n"); + WRITE(p, " int xl = uv1.x * %d / %d;\n", factor, blkW); + WRITE(p, " int xib = uv1.x * %d - xl * %d;\n", factor, blkW); + WRITE(p, " int halfxb = xb / %d;\n", factor); WRITE(p, " sampleUv.x = xib + halfxb * %d;\n", blkW); WRITE(p, " sampleUv.y = yb + xoff;\n"); @@ -161,13 +111,13 @@ void Write32BitSwizzler(char*& p, u32 format, API_TYPE ApiType) void WriteSampleColor(char*& p, const char* colorComp, const char* dest, API_TYPE ApiType) { WRITE(p, - "{\n" - "float2 uv = sampleUv + int2(%d,0);\n" // pixel offset - "uv *= " I_COLORS".w;\n" // scale by two (if wanted) - "uv += " I_COLORS".xy;\n" // move to copyed rect - "uv += float2(0.5, 0.5);\n" // move center of pixel - "uv /= float2(%d, %d);\n" // normlize to [0:1] - "uv.y = 1-uv.y;\n" // ogl foo (disable this line for d3d) + "{\n" // sampleUv is the sample position in (int)gx_coords + "float2 uv = float2(sampleUv) + int2(%d,0);\n" // pixel offset (if more than one pixel is samped) + "uv *= " I_COLORS".w;\n" // scale by two (if wanted) + "uv += " I_COLORS".xy;\n" // move to copyed rect + "uv += float2(0.5, 0.5);\n" // move to center of pixel + "uv /= float2(%d, %d);\n" // normlize to [0:1] + "uv.y = 1.0-uv.y;\n" // ogl foo (disable this line for d3d) "%s = texture(samp0, uv).%s;\n" "}\n", s_incrementSampleXCount, EFB_WIDTH, EFB_HEIGHT, dest, colorComp @@ -462,7 +412,7 @@ void WriteRGBA4443Encoder(char* p,API_TYPE ApiType) void WriteRGBA8Encoder(char* p,API_TYPE ApiType) { - Write32BitSwizzler(p, GX_TF_RGBA8, ApiType); + WriteSwizzler(p, GX_TF_RGBA8, ApiType); WRITE(p, " float cl1 = xb - (halfxb * 2.0);\n"); WRITE(p, " float cl0 = 1.0 - cl1;\n"); @@ -687,7 +637,7 @@ void WriteZ16LEncoder(char* p,API_TYPE ApiType) void WriteZ24Encoder(char* p, API_TYPE ApiType) { - Write32BitSwizzler(p, GX_TF_Z24X8, ApiType); + WriteSwizzler(p, GX_TF_Z24X8, ApiType); WRITE(p, " float cl = xb - (halfxb * 2.0);\n"); -- cgit v1.2.3 From 64a1969e36960ab066c2130a276d005aa272bba9 Mon Sep 17 00:00:00 2001 From: degasus Date: Mon, 25 Nov 2013 16:34:08 +0100 Subject: TextureConverter: fix scoping --- .../VideoCommon/Src/TextureConversionShader.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'Source/Core/VideoCommon/Src/TextureConversionShader.cpp') diff --git a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp index bf625223dd..92c38ca77d 100644 --- a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp @@ -89,7 +89,9 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType) WRITE(p, "{\n" " int2 sampleUv;\n" - " int2 uv1 = int2(gl_FragCoord.xy);\n"); + " int2 uv1 = int2(gl_FragCoord.xy);\n" + " float2 uv0 = float2(0.0, 0.0);\n" + ); WRITE(p, " uv1.x = uv1.x * %d;\n", samples); @@ -110,16 +112,14 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType) void WriteSampleColor(char*& p, const char* colorComp, const char* dest, API_TYPE ApiType) { - WRITE(p, - "{\n" // sampleUv is the sample position in (int)gx_coords - "float2 uv = float2(sampleUv) + int2(%d,0);\n" // pixel offset (if more than one pixel is samped) - "uv *= " I_COLORS".w;\n" // scale by two (if wanted) - "uv += " I_COLORS".xy;\n" // move to copyed rect - "uv += float2(0.5, 0.5);\n" // move to center of pixel - "uv /= float2(%d, %d);\n" // normlize to [0:1] - "uv.y = 1.0-uv.y;\n" // ogl foo (disable this line for d3d) - "%s = texture(samp0, uv).%s;\n" - "}\n", + WRITE(p, // sampleUv is the sample position in (int)gx_coords + "uv0 = float2(sampleUv) + int2(%d,0);\n" // pixel offset (if more than one pixel is samped) + "uv0 *= " I_COLORS".w;\n" // scale by two (if wanted) + "uv0 += " I_COLORS".xy;\n" // move to copyed rect + "uv0 += float2(0.5, 0.5);\n" // move to center of pixel + "uv0 /= float2(%d, %d);\n" // normlize to [0:1] + "uv0.y = 1.0-uv0.y;\n" // ogl foo (disable this line for d3d) + "%s = texture(samp0, uv0).%s;\n", s_incrementSampleXCount, EFB_WIDTH, EFB_HEIGHT, dest, colorComp ); } -- cgit v1.2.3 From 421fd0e16e7de9e599c21fadc2f2b545d95bd1c1 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Mon, 25 Nov 2013 15:36:24 +0000 Subject: Fix OpenGL ES 3. --- Source/Core/VideoCommon/Src/TextureConversionShader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/VideoCommon/Src/TextureConversionShader.cpp') diff --git a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp index 92c38ca77d..b67a899438 100644 --- a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp @@ -113,7 +113,7 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType) void WriteSampleColor(char*& p, const char* colorComp, const char* dest, API_TYPE ApiType) { WRITE(p, // sampleUv is the sample position in (int)gx_coords - "uv0 = float2(sampleUv) + int2(%d,0);\n" // pixel offset (if more than one pixel is samped) + "uv0 = float2(sampleUv + int2(%d, 0));\n" // pixel offset (if more than one pixel is samped) "uv0 *= " I_COLORS".w;\n" // scale by two (if wanted) "uv0 += " I_COLORS".xy;\n" // move to copyed rect "uv0 += float2(0.5, 0.5);\n" // move to center of pixel -- cgit v1.2.3 From 11973d31c18c342ab5636296a7a34e7d9f8460e4 Mon Sep 17 00:00:00 2001 From: degasus Date: Mon, 25 Nov 2013 17:01:35 +0100 Subject: TextureConverter: remove WriteIncrementSampleX --- .../VideoCommon/Src/TextureConversionShader.cpp | 186 +++++++-------------- 1 file changed, 56 insertions(+), 130 deletions(-) (limited to 'Source/Core/VideoCommon/Src/TextureConversionShader.cpp') diff --git a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp index b67a899438..e7db8677eb 100644 --- a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp @@ -21,7 +21,6 @@ static char text[16384]; static bool IntensityConstantAdded = false; -static int s_incrementSampleXCount = 0; namespace TextureConversionShader { @@ -110,7 +109,7 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType) WRITE(p, " sampleUv.y = yb + xoff;\n"); } -void WriteSampleColor(char*& p, const char* colorComp, const char* dest, API_TYPE ApiType) +void WriteSampleColor(char*& p, const char* colorComp, const char* dest, int xoffset, API_TYPE ApiType) { WRITE(p, // sampleUv is the sample position in (int)gx_coords "uv0 = float2(sampleUv + int2(%d, 0));\n" // pixel offset (if more than one pixel is samped) @@ -120,7 +119,7 @@ void WriteSampleColor(char*& p, const char* colorComp, const char* dest, API_TYP "uv0 /= float2(%d, %d);\n" // normlize to [0:1] "uv0.y = 1.0-uv0.y;\n" // ogl foo (disable this line for d3d) "%s = texture(samp0, uv0).%s;\n", - s_incrementSampleXCount, EFB_WIDTH, EFB_HEIGHT, dest, colorComp + xoffset, EFB_WIDTH, EFB_HEIGHT, dest, colorComp ); } @@ -135,25 +134,6 @@ void WriteColorToIntensity(char*& p, const char* src, const char* dest) // don't add IntensityConst.a yet, because doing it later is faster and uses less instructions, due to vectorization } -void WriteIncrementSampleX(char*& p,API_TYPE ApiType) -{ - // the shader compiler apparently isn't smart or aggressive enough to recognize that: - // foo1 = lookup(x) - // x = x + increment; - // foo2 = lookup(x) - // x = x + increment; - // foo3 = lookup(x) - // can be replaced with this: - // foo1 = lookup(x + 0.0 * increment) - // foo2 = lookup(x + 1.0 * increment) - // foo3 = lookup(x + 2.0 * increment) - // which looks like the same operations but uses considerably fewer ALU instruction slots. - // thus, instead of using the former method, we only increment a counter internally here, - // and we wait until WriteSampleColor to write out the constant multiplier - // to achieve the increment as in the latter case. - s_incrementSampleXCount++; -} - void WriteToBitDepth(char*& p, u8 depth, const char* src, const char* dest) { WRITE(p, " %s = floor(%s * 255.0 / exp2(8.0 - %d.0));\n", dest, src, depth); @@ -163,7 +143,6 @@ void WriteEncoderEnd(char* p, API_TYPE ApiType) { WRITE(p, "}\n"); IntensityConstantAdded = false; - s_incrementSampleXCount = 0; } void WriteI8Encoder(char* p, API_TYPE ApiType) @@ -171,19 +150,16 @@ void WriteI8Encoder(char* p, API_TYPE ApiType) WriteSwizzler(p, GX_TF_I8, ApiType); WRITE(p, " float3 texSample;\n"); - WriteSampleColor(p, "rgb", "texSample", ApiType); + WriteSampleColor(p, "rgb", "texSample", 0, ApiType); WriteColorToIntensity(p, "texSample", "ocol0.b"); - WriteIncrementSampleX(p, ApiType); - WriteSampleColor(p, "rgb", "texSample", ApiType); + WriteSampleColor(p, "rgb", "texSample", 1, ApiType); WriteColorToIntensity(p, "texSample", "ocol0.g"); - WriteIncrementSampleX(p, ApiType); - WriteSampleColor(p, "rgb", "texSample", ApiType); + WriteSampleColor(p, "rgb", "texSample", 2, ApiType); WriteColorToIntensity(p, "texSample", "ocol0.r"); - WriteIncrementSampleX(p, ApiType); - WriteSampleColor(p, "rgb", "texSample", ApiType); + WriteSampleColor(p, "rgb", "texSample", 3, ApiType); WriteColorToIntensity(p, "texSample", "ocol0.a"); WRITE(p, " ocol0.rgba += IntensityConst.aaaa;\n"); // see WriteColorToIntensity @@ -198,35 +174,28 @@ void WriteI4Encoder(char* p, API_TYPE ApiType) WRITE(p, " float4 color0;\n"); WRITE(p, " float4 color1;\n"); - WriteSampleColor(p, "rgb", "texSample", ApiType); + WriteSampleColor(p, "rgb", "texSample", 0, ApiType); WriteColorToIntensity(p, "texSample", "color0.b"); - WriteIncrementSampleX(p, ApiType); - WriteSampleColor(p, "rgb", "texSample", ApiType); + WriteSampleColor(p, "rgb", "texSample", 1, ApiType); WriteColorToIntensity(p, "texSample", "color1.b"); - WriteIncrementSampleX(p, ApiType); - WriteSampleColor(p, "rgb", "texSample", ApiType); + WriteSampleColor(p, "rgb", "texSample", 2, ApiType); WriteColorToIntensity(p, "texSample", "color0.g"); - WriteIncrementSampleX(p, ApiType); - WriteSampleColor(p, "rgb", "texSample", ApiType); + WriteSampleColor(p, "rgb", "texSample", 3, ApiType); WriteColorToIntensity(p, "texSample", "color1.g"); - WriteIncrementSampleX(p, ApiType); - WriteSampleColor(p, "rgb", "texSample", ApiType); + WriteSampleColor(p, "rgb", "texSample", 4, ApiType); WriteColorToIntensity(p, "texSample", "color0.r"); - WriteIncrementSampleX(p, ApiType); - WriteSampleColor(p, "rgb", "texSample", ApiType); + WriteSampleColor(p, "rgb", "texSample", 5, ApiType); WriteColorToIntensity(p, "texSample", "color1.r"); - WriteIncrementSampleX(p, ApiType); - WriteSampleColor(p, "rgb", "texSample", ApiType); + WriteSampleColor(p, "rgb", "texSample", 6, ApiType); WriteColorToIntensity(p, "texSample", "color0.a"); - WriteIncrementSampleX(p, ApiType); - WriteSampleColor(p, "rgb", "texSample", ApiType); + WriteSampleColor(p, "rgb", "texSample", 7, ApiType); WriteColorToIntensity(p, "texSample", "color1.a"); WRITE(p, " color0.rgba += IntensityConst.aaaa;\n"); @@ -244,12 +213,11 @@ void WriteIA8Encoder(char* p,API_TYPE ApiType) WriteSwizzler(p, GX_TF_IA8, ApiType); WRITE(p, " float4 texSample;\n"); - WriteSampleColor(p, "rgba", "texSample", ApiType); + WriteSampleColor(p, "rgba", "texSample", 0, ApiType); WRITE(p, " ocol0.b = texSample.a;\n"); WriteColorToIntensity(p, "texSample", "ocol0.g"); - WriteIncrementSampleX(p, ApiType); - WriteSampleColor(p, "rgba", "texSample", ApiType); + WriteSampleColor(p, "rgba", "texSample", 1, ApiType); WRITE(p, " ocol0.r = texSample.a;\n"); WriteColorToIntensity(p, "texSample", "ocol0.a"); @@ -265,22 +233,19 @@ void WriteIA4Encoder(char* p,API_TYPE ApiType) WRITE(p, " float4 color0;\n"); WRITE(p, " float4 color1;\n"); - WriteSampleColor(p, "rgba", "texSample", ApiType); + WriteSampleColor(p, "rgba", "texSample", 0, ApiType); WRITE(p, " color0.b = texSample.a;\n"); WriteColorToIntensity(p, "texSample", "color1.b"); - WriteIncrementSampleX(p, ApiType); - WriteSampleColor(p, "rgba", "texSample", ApiType); + WriteSampleColor(p, "rgba", "texSample", 1, ApiType); WRITE(p, " color0.g = texSample.a;\n"); WriteColorToIntensity(p, "texSample", "color1.g"); - WriteIncrementSampleX(p, ApiType); - WriteSampleColor(p, "rgba", "texSample", ApiType); + WriteSampleColor(p, "rgba", "texSample", 2, ApiType); WRITE(p, " color0.r = texSample.a;\n"); WriteColorToIntensity(p, "texSample", "color1.r"); - WriteIncrementSampleX(p, ApiType); - WriteSampleColor(p, "rgba", "texSample", ApiType); + WriteSampleColor(p, "rgba", "texSample", 3, ApiType); WRITE(p, " color0.a = texSample.a;\n"); WriteColorToIntensity(p, "texSample", "color1.a"); @@ -297,9 +262,8 @@ void WriteRGB565Encoder(char* p,API_TYPE ApiType) { WriteSwizzler(p, GX_TF_RGB565, ApiType); - WriteSampleColor(p, "rgb", "float3 texSample0", ApiType); - WriteIncrementSampleX(p, ApiType); - WriteSampleColor(p, "rgb", "float3 texSample1", ApiType); + WriteSampleColor(p, "rgb", "float3 texSample0", 0, ApiType); + WriteSampleColor(p, "rgb", "float3 texSample1", 1, ApiType); WRITE(p, " float2 texRs = float2(texSample0.r, texSample1.r);\n"); WRITE(p, " float2 texGs = float2(texSample0.g, texSample1.g);\n"); WRITE(p, " float2 texBs = float2(texSample0.b, texSample1.b);\n"); @@ -326,7 +290,7 @@ void WriteRGB5A3Encoder(char* p,API_TYPE ApiType) WRITE(p, " float gUpper;\n"); WRITE(p, " float gLower;\n"); - WriteSampleColor(p, "rgba", "texSample", ApiType); + WriteSampleColor(p, "rgba", "texSample", 0, ApiType); // 0.8784 = 224 / 255 which is the maximum alpha value that can be represented in 3 bits WRITE(p, "if(texSample.a > 0.878f) {\n"); @@ -353,9 +317,8 @@ void WriteRGB5A3Encoder(char* p,API_TYPE ApiType) WRITE(p, "}\n"); - WriteIncrementSampleX(p, ApiType); - WriteSampleColor(p, "rgba", "texSample", ApiType); + WriteSampleColor(p, "rgba", "texSample", 1, ApiType); WRITE(p, "if(texSample.a > 0.878f) {\n"); @@ -392,15 +355,13 @@ void WriteRGBA4443Encoder(char* p,API_TYPE ApiType) WRITE(p, " float4 color0;\n"); WRITE(p, " float4 color1;\n"); - WriteSampleColor(p, "rgba", "texSample", ApiType); + WriteSampleColor(p, "rgba", "texSample", 0, ApiType); WriteToBitDepth(p, 3, "texSample.a", "color0.b"); WriteToBitDepth(p, 4, "texSample.r", "color1.b"); WriteToBitDepth(p, 4, "texSample.g", "color0.g"); WriteToBitDepth(p, 4, "texSample.b", "color1.g"); - WriteIncrementSampleX(p, ApiType); - - WriteSampleColor(p, "rgba", "texSample", ApiType); + WriteSampleColor(p, "rgba", "texSample", 1, ApiType); WriteToBitDepth(p, 3, "texSample.a", "color0.r"); WriteToBitDepth(p, 4, "texSample.r", "color1.r"); WriteToBitDepth(p, 4, "texSample.g", "color0.a"); @@ -421,15 +382,13 @@ void WriteRGBA8Encoder(char* p,API_TYPE ApiType) WRITE(p, " float4 color0;\n"); WRITE(p, " float4 color1;\n"); - WriteSampleColor(p, "rgba", "texSample", ApiType); + WriteSampleColor(p, "rgba", "texSample", 0, ApiType); WRITE(p, " color0.b = texSample.a;\n"); WRITE(p, " color0.g = texSample.r;\n"); WRITE(p, " color1.b = texSample.g;\n"); WRITE(p, " color1.g = texSample.b;\n"); - WriteIncrementSampleX(p, ApiType); - - WriteSampleColor(p, "rgba", "texSample", ApiType); + WriteSampleColor(p, "rgba", "texSample", 1, ApiType); WRITE(p, " color0.r = texSample.a;\n"); WRITE(p, " color0.a = texSample.r;\n"); WRITE(p, " color1.r = texSample.g;\n"); @@ -446,28 +405,14 @@ void WriteC4Encoder(char* p, const char* comp,API_TYPE ApiType) WRITE(p, " float4 color0;\n"); WRITE(p, " float4 color1;\n"); - WriteSampleColor(p, comp, "color0.b", ApiType); - WriteIncrementSampleX(p, ApiType); - - WriteSampleColor(p, comp, "color1.b", ApiType); - WriteIncrementSampleX(p, ApiType); - - WriteSampleColor(p, comp, "color0.g", ApiType); - WriteIncrementSampleX(p, ApiType); - - WriteSampleColor(p, comp, "color1.g", ApiType); - WriteIncrementSampleX(p, ApiType); - - WriteSampleColor(p, comp, "color0.r", ApiType); - WriteIncrementSampleX(p, ApiType); - - WriteSampleColor(p, comp, "color1.r", ApiType); - WriteIncrementSampleX(p, ApiType); - - WriteSampleColor(p, comp, "color0.a", ApiType); - WriteIncrementSampleX(p, ApiType); - - WriteSampleColor(p, comp, "color1.a", ApiType); + WriteSampleColor(p, comp, "color0.b", 0, ApiType); + WriteSampleColor(p, comp, "color1.b", 1, ApiType); + WriteSampleColor(p, comp, "color0.g", 2, ApiType); + WriteSampleColor(p, comp, "color1.g", 3, ApiType); + WriteSampleColor(p, comp, "color0.r", 4, ApiType); + WriteSampleColor(p, comp, "color1.r", 5, ApiType); + WriteSampleColor(p, comp, "color0.a", 6, ApiType); + WriteSampleColor(p, comp, "color1.a", 7, ApiType); WriteToBitDepth(p, 4, "color0", "color0"); WriteToBitDepth(p, 4, "color1", "color1"); @@ -480,16 +425,10 @@ void WriteC8Encoder(char* p, const char* comp,API_TYPE ApiType) { WriteSwizzler(p, GX_CTF_R8, ApiType); - WriteSampleColor(p, comp, "ocol0.b", ApiType); - WriteIncrementSampleX(p, ApiType); - - WriteSampleColor(p, comp, "ocol0.g", ApiType); - WriteIncrementSampleX(p, ApiType); - - WriteSampleColor(p, comp, "ocol0.r", ApiType); - WriteIncrementSampleX(p, ApiType); - - WriteSampleColor(p, comp, "ocol0.a", ApiType); + WriteSampleColor(p, comp, "ocol0.b", 0, ApiType); + WriteSampleColor(p, comp, "ocol0.g", 1, ApiType); + WriteSampleColor(p, comp, "ocol0.r", 2, ApiType); + WriteSampleColor(p, comp, "ocol0.a", 3, ApiType); WriteEncoderEnd(p, ApiType); } @@ -501,22 +440,19 @@ void WriteCC4Encoder(char* p, const char* comp,API_TYPE ApiType) WRITE(p, " float4 color0;\n"); WRITE(p, " float4 color1;\n"); - WriteSampleColor(p, comp, "texSample", ApiType); + WriteSampleColor(p, comp, "texSample", 0, ApiType); WRITE(p, " color0.b = texSample.x;\n"); WRITE(p, " color1.b = texSample.y;\n"); - WriteIncrementSampleX(p, ApiType); - WriteSampleColor(p, comp, "texSample", ApiType); + WriteSampleColor(p, comp, "texSample", 1, ApiType); WRITE(p, " color0.g = texSample.x;\n"); WRITE(p, " color1.g = texSample.y;\n"); - WriteIncrementSampleX(p, ApiType); - WriteSampleColor(p, comp, "texSample", ApiType); + WriteSampleColor(p, comp, "texSample", 2, ApiType); WRITE(p, " color0.r = texSample.x;\n"); WRITE(p, " color1.r = texSample.y;\n"); - WriteIncrementSampleX(p, ApiType); - WriteSampleColor(p, comp, "texSample", ApiType); + WriteSampleColor(p, comp, "texSample", 3, ApiType); WRITE(p, " color0.a = texSample.x;\n"); WRITE(p, " color1.a = texSample.y;\n"); @@ -531,10 +467,8 @@ void WriteCC8Encoder(char* p, const char* comp, API_TYPE ApiType) { WriteSwizzler(p, GX_CTF_RA8, ApiType); - WriteSampleColor(p, comp, "ocol0.bg", ApiType); - WriteIncrementSampleX(p, ApiType); - - WriteSampleColor(p, comp, "ocol0.ra", ApiType); + WriteSampleColor(p, comp, "ocol0.bg", 0, ApiType); + WriteSampleColor(p, comp, "ocol0.ra", 1, ApiType); WriteEncoderEnd(p, ApiType); } @@ -545,19 +479,16 @@ void WriteZ8Encoder(char* p, const char* multiplier,API_TYPE ApiType) WRITE(p, " float depth;\n"); - WriteSampleColor(p, "b", "depth", ApiType); + WriteSampleColor(p, "b", "depth", 0, ApiType); WRITE(p, "ocol0.b = frac(depth * %s);\n", multiplier); - WriteIncrementSampleX(p, ApiType); - WriteSampleColor(p, "b", "depth", ApiType); + WriteSampleColor(p, "b", "depth", 1, ApiType); WRITE(p, "ocol0.g = frac(depth * %s);\n", multiplier); - WriteIncrementSampleX(p, ApiType); - WriteSampleColor(p, "b", "depth", ApiType); + WriteSampleColor(p, "b", "depth", 2, ApiType); WRITE(p, "ocol0.r = frac(depth * %s);\n", multiplier); - WriteIncrementSampleX(p, ApiType); - WriteSampleColor(p, "b", "depth", ApiType); + WriteSampleColor(p, "b", "depth", 3, ApiType); WRITE(p, "ocol0.a = frac(depth * %s);\n", multiplier); WriteEncoderEnd(p, ApiType); @@ -572,7 +503,7 @@ void WriteZ16Encoder(char* p,API_TYPE ApiType) // byte order is reversed - WriteSampleColor(p, "b", "depth", ApiType); + WriteSampleColor(p, "b", "depth", 0, ApiType); WRITE(p, " depth *= 16777215.0;\n"); WRITE(p, " expanded.r = floor(depth / (256.0 * 256.0));\n"); @@ -582,9 +513,7 @@ void WriteZ16Encoder(char* p,API_TYPE ApiType) WRITE(p, " ocol0.b = expanded.g / 255.0;\n"); WRITE(p, " ocol0.g = expanded.r / 255.0;\n"); - WriteIncrementSampleX(p, ApiType); - - WriteSampleColor(p, "b", "depth", ApiType); + WriteSampleColor(p, "b", "depth", 1, ApiType); WRITE(p, " depth *= 16777215.0;\n"); WRITE(p, " expanded.r = floor(depth / (256.0 * 256.0));\n"); @@ -606,7 +535,7 @@ void WriteZ16LEncoder(char* p,API_TYPE ApiType) // byte order is reversed - WriteSampleColor(p, "b", "depth", ApiType); + WriteSampleColor(p, "b", "depth", 0, ApiType); WRITE(p, " depth *= 16777215.0;\n"); WRITE(p, " expanded.r = floor(depth / (256.0 * 256.0));\n"); @@ -618,9 +547,7 @@ void WriteZ16LEncoder(char* p,API_TYPE ApiType) WRITE(p, " ocol0.b = expanded.b / 255.0;\n"); WRITE(p, " ocol0.g = expanded.g / 255.0;\n"); - WriteIncrementSampleX(p, ApiType); - - WriteSampleColor(p, "b", "depth", ApiType); + WriteSampleColor(p, "b", "depth", 1, ApiType); WRITE(p, " depth *= 16777215.0;\n"); WRITE(p, " expanded.r = floor(depth / (256.0 * 256.0));\n"); @@ -646,9 +573,8 @@ void WriteZ24Encoder(char* p, API_TYPE ApiType) WRITE(p, " float3 expanded0;\n"); WRITE(p, " float3 expanded1;\n"); - WriteSampleColor(p, "b", "depth0", ApiType); - WriteIncrementSampleX(p, ApiType); - WriteSampleColor(p, "b", "depth1", ApiType); + WriteSampleColor(p, "b", "depth0", 0, ApiType); + WriteSampleColor(p, "b", "depth1", 1, ApiType); for (int i = 0; i < 2; i++) { -- cgit v1.2.3 From 687097d4bc1ee2f8ee60011280823e01907a986a Mon Sep 17 00:00:00 2001 From: degasus Date: Mon, 9 Dec 2013 12:33:50 +0100 Subject: OGL: use integer uniforms for efb2ram texture converter --- .../Core/VideoCommon/Src/TextureConversionShader.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'Source/Core/VideoCommon/Src/TextureConversionShader.cpp') diff --git a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp index e7db8677eb..f271111851 100644 --- a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp @@ -62,7 +62,7 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType) { // left, top, of source rectangle within source texture // width of the destination rectangle, scale_factor (1 or 2) - WRITE(p, "uniform float4 " I_COLORS";\n"); + WRITE(p, "uniform int4 " I_COLORS";\n"); int blkW = TexDecoder_GetBlockWidthInTexels(format); int blkH = TexDecoder_GetBlockHeightInTexels(format); @@ -97,7 +97,7 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType) WRITE(p, " int yl = uv1.y / %d;\n", blkH); WRITE(p, " int yb = yl * %d;\n", blkH); WRITE(p, " int yoff = uv1.y - yb;\n"); - WRITE(p, " int xp = uv1.x + yoff * int(" I_COLORS".z);\n"); + WRITE(p, " int xp = uv1.x + yoff * " I_COLORS".z;\n"); WRITE(p, " int xel = xp / %d;\n", samples == 1 ? factor : blkW); WRITE(p, " int xb = xel / %d;\n", blkH); WRITE(p, " int xoff = xel - xb * %d;\n", blkH); @@ -111,13 +111,13 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType) void WriteSampleColor(char*& p, const char* colorComp, const char* dest, int xoffset, API_TYPE ApiType) { - WRITE(p, // sampleUv is the sample position in (int)gx_coords - "uv0 = float2(sampleUv + int2(%d, 0));\n" // pixel offset (if more than one pixel is samped) - "uv0 *= " I_COLORS".w;\n" // scale by two (if wanted) - "uv0 += " I_COLORS".xy;\n" // move to copyed rect - "uv0 += float2(0.5, 0.5);\n" // move to center of pixel - "uv0 /= float2(%d, %d);\n" // normlize to [0:1] - "uv0.y = 1.0-uv0.y;\n" // ogl foo (disable this line for d3d) + WRITE(p, // sampleUv is the sample position in (int)gx_coords + "uv0 = float2(sampleUv + int2(%d, 0)" // pixel offset (if more than one pixel is samped) + " + " I_COLORS".xy);\n" // move to copyed rect + "uv0 += float2(0.5, 0.5);\n" // move to center of pixel + "uv0 *= float(" I_COLORS".w);\n" // scale by two if needed (this will move to pixels border to filter linear) + "uv0 /= float2(%d, %d);\n" // normlize to [0:1] + "uv0.y = 1.0-uv0.y;\n" // ogl foo (disable this line for d3d) "%s = texture(samp0, uv0).%s;\n", xoffset, EFB_WIDTH, EFB_HEIGHT, dest, colorComp ); -- cgit v1.2.3