diff --git a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp index 716a4552d6..c38504c829 100644 --- a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp @@ -67,17 +67,19 @@ u16 GetEncodedSampleCount(u32 format) // block dimensions : widthStride, heightStride // texture dims : width, height, x offset, y offset -void WriteSwizzler(char*& p, u32 format) +void WriteSwizzler(char*& p, u32 format,bool HLSL) { WRITE(p, "uniform float4 blkDims : register(c%d);\n", C_COLORMATRIX); - WRITE(p, "uniform float4 textureDims : register(c%d);\n", C_COLORMATRIX + 1); + WRITE(p, "uniform float4 textureDims : register(c%d);\n", C_COLORMATRIX + 1); float blkW = (float)TexDecoder_GetBlockWidthInTexels(format); float blkH = (float)TexDecoder_GetBlockHeightInTexels(format); float samples = (float)GetEncodedSampleCount(format); - - WRITE(p, - "uniform samplerRECT samp0 : register(s0);\n" + if(HLSL) + WRITE(p,"uniform sampler samp0 : register(s0);\n"); + else + WRITE(p,"uniform samplerRECT samp0 : register(s0);\n"); + WRITE(p, "void main(\n" " out float4 ocol0 : COLOR0,\n" " in float2 uv0 : TEXCOORD0)\n" @@ -87,7 +89,7 @@ void WriteSwizzler(char*& p, u32 format) WRITE(p, " uv1.x = uv1.x * %f;\n", samples); - WRITE(p, " float xl = floor(uv1.x / %f);\n", blkW); + WRITE(p, " float xl = floor(uv1.x / %f);\n", blkW); WRITE(p, " float xib = uv1.x - (xl * %f);\n", blkW); WRITE(p, " float yl = floor(uv1.y / %f);\n", blkH); WRITE(p, " float yb = yl * %f;\n", blkH); @@ -100,16 +102,23 @@ void WriteSwizzler(char*& p, u32 format) WRITE(p, " sampleUv.x = xib + (xb * %f);\n", blkW); WRITE(p, " sampleUv.y = yb + xoff;\n"); - WRITE(p, " sampleUv = sampleUv * blkDims.xy;\n" - " sampleUv.y = textureDims.y - sampleUv.y;\n" + WRITE(p, " sampleUv = sampleUv * blkDims.xy;\n"); + + if(!HLSL) + WRITE(p," sampleUv.y = textureDims.y - sampleUv.y;\n"); - " sampleUv.x = sampleUv.x + textureDims.z;\n" + WRITE(p, " sampleUv.x = sampleUv.x + textureDims.z;\n" " sampleUv.y = sampleUv.y + textureDims.w;\n"); + if(HLSL) + { + WRITE(p, " sampleUv.x = sampleUv.x / blkDims.z;\n" + " sampleUv.y = sampleUv.y / blkDims.w;\n"); + } } // block dimensions : widthStride, heightStride // texture dims : width, height, x offset, y offset -void Write32BitSwizzler(char*& p, u32 format) +void Write32BitSwizzler(char*& p, u32 format, bool HLSL) { WRITE(p, "uniform float4 blkDims : register(c%d);\n", C_COLORMATRIX); WRITE(p, "uniform float4 textureDims : register(c%d);\n", C_COLORMATRIX + 1); @@ -118,9 +127,11 @@ void Write32BitSwizzler(char*& p, u32 format) float blkH = (float)TexDecoder_GetBlockHeightInTexels(format); // 32 bit textures (RGBA8 and Z24) are store in 2 cache line increments - - WRITE(p, - "uniform samplerRECT samp0 : register(s0);\n" + if(HLSL) + WRITE(p,"uniform sampler samp0 : register(s0);\n"); + else + WRITE(p,"uniform samplerRECT samp0 : register(s0);\n"); + WRITE(p, "void main(\n" " out float4 ocol0 : COLOR0,\n" " in float2 uv0 : TEXCOORD0)\n" @@ -145,15 +156,26 @@ void Write32BitSwizzler(char*& p, u32 format) WRITE(p, " sampleUv.x = xib + (halfxb * %f);\n", blkW); WRITE(p, " sampleUv.y = yb + xoff;\n"); WRITE(p, " sampleUv = sampleUv * blkDims.xy;\n"); - WRITE(p, " sampleUv.y = textureDims.y - sampleUv.y;\n"); + + if(!HLSL) + WRITE(p, " sampleUv.y = textureDims.y - sampleUv.y;\n"); WRITE(p, " sampleUv.x = sampleUv.x + textureDims.z;\n"); WRITE(p, " sampleUv.y = sampleUv.y + textureDims.w;\n"); + + if(HLSL) + { + WRITE(p, " sampleUv.x = sampleUv.x / blkDims.z;\n" + " sampleUv.y = sampleUv.y / blkDims.w;\n"); + } } -void WriteSampleColor(char*& p, const char* colorComp, const char* dest) +void WriteSampleColor(char*& p, const char* colorComp, const char* dest,bool HLSL) { - WRITE(p, " %s = texRECT(samp0, sampleUv).%s;\n", dest, colorComp); + if(HLSL) + WRITE(p, " %s = tex2D(samp0, sampleUv).%s;\n", dest, colorComp); + else + WRITE(p, " %s = texRECT(samp0, sampleUv).%s;\n", dest, colorComp); } void WriteColorToIntensity(char*& p, const char* src, const char* dest) @@ -163,13 +185,15 @@ void WriteColorToIntensity(char*& p, const char* src, const char* dest) WRITE(p, " float4 IntensityConst = float4(0.257f,0.504f,0.098f,0.0625f);\n"); IntensityConstantAdded = true; } - //WRITE(p, " %s = (0.257f * %s.r) + (0.504f * %s.g) + (0.098f * %s.b) + 0.0625f;\n", dest, src, src, src); WRITE(p, " %s = dot(IntensityConst.rgb, %s.rgb) + IntensityConst.a;\n", dest, src); } -void WriteIncrementSampleX(char*& p) +void WriteIncrementSampleX(char*& p,bool HLSL) { - WRITE(p, " sampleUv.x = sampleUv.x + blkDims.x;\n"); + if(HLSL) + WRITE(p, " sampleUv.x = sampleUv.x + blkDims.x / blkDims.z;\n"); + else + WRITE(p, " sampleUv.x = sampleUv.x + blkDims.x;\n"); } void WriteToBitDepth(char*& p, u8 depth, const char* src, const char* dest) @@ -184,65 +208,65 @@ void WriteEncoderEnd(char* p) IntensityConstantAdded = false; } -void WriteI8Encoder(char* p) +void WriteI8Encoder(char* p, bool HLSL) { - WriteSwizzler(p, GX_TF_I8); + WriteSwizzler(p, GX_TF_I8,HLSL); WRITE(p, " float3 texSample;\n"); - WriteSampleColor(p, "rgb", "texSample"); + WriteSampleColor(p, "rgb", "texSample",HLSL); WriteColorToIntensity(p, "texSample", "ocol0.b"); - WriteIncrementSampleX(p); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, "rgb", "texSample"); + WriteSampleColor(p, "rgb", "texSample",HLSL); WriteColorToIntensity(p, "texSample", "ocol0.g"); - WriteIncrementSampleX(p); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, "rgb", "texSample"); + WriteSampleColor(p, "rgb", "texSample",HLSL); WriteColorToIntensity(p, "texSample", "ocol0.r"); - WriteIncrementSampleX(p); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, "rgb", "texSample"); + WriteSampleColor(p, "rgb", "texSample",HLSL); WriteColorToIntensity(p, "texSample", "ocol0.a"); WriteEncoderEnd(p); } -void WriteI4Encoder(char* p) +void WriteI4Encoder(char* p, bool HLSL) { - WriteSwizzler(p, GX_TF_I4); + WriteSwizzler(p, GX_TF_I4,HLSL); WRITE(p, " float3 texSample;\n"); WRITE(p, " float4 color0;\n"); WRITE(p, " float4 color1;\n"); - WriteSampleColor(p, "rgb", "texSample"); + WriteSampleColor(p, "rgb", "texSample",HLSL); WriteColorToIntensity(p, "texSample", "color0.b"); - WriteIncrementSampleX(p); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, "rgb", "texSample"); + WriteSampleColor(p, "rgb", "texSample",HLSL); WriteColorToIntensity(p, "texSample", "color1.b"); - WriteIncrementSampleX(p); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, "rgb", "texSample"); + WriteSampleColor(p, "rgb", "texSample",HLSL); WriteColorToIntensity(p, "texSample", "color0.g"); - WriteIncrementSampleX(p); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, "rgb", "texSample"); + WriteSampleColor(p, "rgb", "texSample",HLSL); WriteColorToIntensity(p, "texSample", "color1.g"); - WriteIncrementSampleX(p); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, "rgb", "texSample"); + WriteSampleColor(p, "rgb", "texSample",HLSL); WriteColorToIntensity(p, "texSample", "color0.r"); - WriteIncrementSampleX(p); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, "rgb", "texSample"); + WriteSampleColor(p, "rgb", "texSample",HLSL); WriteColorToIntensity(p, "texSample", "color1.r"); - WriteIncrementSampleX(p); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, "rgb", "texSample"); + WriteSampleColor(p, "rgb", "texSample",HLSL); WriteColorToIntensity(p, "texSample", "color0.a"); - WriteIncrementSampleX(p); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, "rgb", "texSample"); + WriteSampleColor(p, "rgb", "texSample",HLSL); WriteColorToIntensity(p, "texSample", "color1.a"); WriteToBitDepth(p, 4, "color0", "color0"); @@ -252,46 +276,46 @@ void WriteI4Encoder(char* p) WriteEncoderEnd(p); } -void WriteIA8Encoder(char* p) +void WriteIA8Encoder(char* p,bool HLSL) { - WriteSwizzler(p, GX_TF_IA8); + WriteSwizzler(p, GX_TF_IA8,HLSL); WRITE(p, " float4 texSample;\n"); - WriteSampleColor(p, "rgba", "texSample"); + WriteSampleColor(p, "rgba", "texSample",HLSL); WRITE(p, " ocol0.b = texSample.a;\n"); WriteColorToIntensity(p, "texSample", "ocol0.g"); - WriteIncrementSampleX(p); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, "rgba", "texSample"); + WriteSampleColor(p, "rgba", "texSample",HLSL); WRITE(p, " ocol0.r = texSample.a;\n"); WriteColorToIntensity(p, "texSample", "ocol0.a"); WriteEncoderEnd(p); } -void WriteIA4Encoder(char* p) +void WriteIA4Encoder(char* p,bool HLSL) { - WriteSwizzler(p, GX_TF_IA4); + WriteSwizzler(p, GX_TF_IA4,HLSL); WRITE(p, " float4 texSample;\n"); WRITE(p, " float4 color0;\n"); WRITE(p, " float4 color1;\n"); - WriteSampleColor(p, "rgba", "texSample"); + WriteSampleColor(p, "rgba", "texSample",HLSL); WRITE(p, " color0.b = texSample.a;\n"); WriteColorToIntensity(p, "texSample", "color1.b"); - WriteIncrementSampleX(p); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, "rgba", "texSample"); + WriteSampleColor(p, "rgba", "texSample",HLSL); WRITE(p, " color0.g = texSample.a;\n"); WriteColorToIntensity(p, "texSample", "color1.g"); - WriteIncrementSampleX(p); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, "rgba", "texSample"); + WriteSampleColor(p, "rgba", "texSample",HLSL); WRITE(p, " color0.r = texSample.a;\n"); WriteColorToIntensity(p, "texSample", "color1.r"); - WriteIncrementSampleX(p); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, "rgba", "texSample"); + WriteSampleColor(p, "rgba", "texSample",HLSL); WRITE(p, " color0.a = texSample.a;\n"); WriteColorToIntensity(p, "texSample", "color1.a"); @@ -302,16 +326,16 @@ void WriteIA4Encoder(char* p) WriteEncoderEnd(p); } -void WriteRGB565Encoder(char* p) +void WriteRGB565Encoder(char* p,bool HLSL) { - WriteSwizzler(p, GX_TF_RGB565); + WriteSwizzler(p, GX_TF_RGB565,HLSL); WRITE(p, " float3 texSample;\n"); WRITE(p, " float gInt;\n"); WRITE(p, " float gUpper;\n"); WRITE(p, " float gLower;\n"); - WriteSampleColor(p, "rgb", "texSample"); + WriteSampleColor(p, "rgb", "texSample",HLSL); WriteToBitDepth(p, 6, "texSample.g", "gInt"); WRITE(p, " gUpper = floor(gInt / 8.0f);\n"); WRITE(p, " gLower = gInt - gUpper * 8.0f;\n"); @@ -321,9 +345,9 @@ void WriteRGB565Encoder(char* p) WriteToBitDepth(p, 5, "texSample.b", "ocol0.g"); WRITE(p, " ocol0.g = ocol0.g + gLower * 32.0f;\n"); - WriteIncrementSampleX(p); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, "rgb", "texSample"); + WriteSampleColor(p, "rgb", "texSample",HLSL); WriteToBitDepth(p, 6, "texSample.g", "gInt"); WRITE(p, " gUpper = floor(gInt / 8.0f);\n"); WRITE(p, " gLower = gInt - gUpper * 8.0f;\n"); @@ -337,16 +361,16 @@ void WriteRGB565Encoder(char* p) WriteEncoderEnd(p); } -void WriteRGB5A3Encoder(char* p) +void WriteRGB5A3Encoder(char* p,bool HLSL) { - WriteSwizzler(p, GX_TF_RGB5A3); + WriteSwizzler(p, GX_TF_RGB5A3,HLSL); WRITE(p, " float4 texSample;\n"); WRITE(p, " float color0;\n"); WRITE(p, " float gUpper;\n"); WRITE(p, " float gLower;\n"); - WriteSampleColor(p, "rgba", "texSample"); + WriteSampleColor(p, "rgba", "texSample",HLSL); // 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"); @@ -373,9 +397,9 @@ void WriteRGB5A3Encoder(char* p) WRITE(p, "}\n"); - WriteIncrementSampleX(p); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, "rgba", "texSample"); + WriteSampleColor(p, "rgba", "texSample",HLSL); WRITE(p, "if(texSample.a > 0.878f) {\n"); @@ -404,23 +428,23 @@ void WriteRGB5A3Encoder(char* p) WriteEncoderEnd(p); } -void WriteRGBA4443Encoder(char* p) +void WriteRGBA4443Encoder(char* p,bool HLSL) { - WriteSwizzler(p, GX_TF_RGB5A3); + WriteSwizzler(p, GX_TF_RGB5A3,HLSL); WRITE(p, " float4 texSample;\n"); WRITE(p, " float4 color0;\n"); WRITE(p, " float4 color1;\n"); - WriteSampleColor(p, "rgba", "texSample"); + WriteSampleColor(p, "rgba", "texSample",HLSL); 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); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, "rgba", "texSample"); + WriteSampleColor(p, "rgba", "texSample",HLSL); WriteToBitDepth(p, 3, "texSample.a", "color0.r"); WriteToBitDepth(p, 4, "texSample.r", "color1.r"); WriteToBitDepth(p, 4, "texSample.g", "color0.a"); @@ -430,9 +454,9 @@ void WriteRGBA4443Encoder(char* p) WriteEncoderEnd(p); } -void WriteRGBA8Encoder(char* p) +void WriteRGBA8Encoder(char* p,bool HLSL) { - Write32BitSwizzler(p, GX_TF_RGBA8); + Write32BitSwizzler(p, GX_TF_RGBA8,HLSL); WRITE(p, " float cl1 = xb - (halfxb * 2);\n"); WRITE(p, " float cl0 = 1.0f - cl1;\n"); @@ -441,15 +465,15 @@ void WriteRGBA8Encoder(char* p) WRITE(p, " float4 color0;\n"); WRITE(p, " float4 color1;\n"); - WriteSampleColor(p, "rgba", "texSample"); + WriteSampleColor(p, "rgba", "texSample",HLSL); 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); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, "rgba", "texSample"); + WriteSampleColor(p, "rgba", "texSample",HLSL); WRITE(p, " color0.r = texSample.a;\n"); WRITE(p, " color0.a = texSample.r;\n"); WRITE(p, " color1.r = texSample.g;\n"); @@ -460,34 +484,34 @@ void WriteRGBA8Encoder(char* p) WriteEncoderEnd(p); } -void WriteC4Encoder(char* p, const char* comp) +void WriteC4Encoder(char* p, const char* comp,bool HLSL) { - WriteSwizzler(p, GX_CTF_R4); + WriteSwizzler(p, GX_CTF_R4,HLSL); WRITE(p, " float4 color0;\n"); WRITE(p, " float4 color1;\n"); - WriteSampleColor(p, comp, "color0.b"); - WriteIncrementSampleX(p); + WriteSampleColor(p, comp, "color0.b",HLSL); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, comp, "color1.b"); - WriteIncrementSampleX(p); + WriteSampleColor(p, comp, "color1.b",HLSL); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, comp, "color0.g"); - WriteIncrementSampleX(p); + WriteSampleColor(p, comp, "color0.g",HLSL); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, comp, "color1.g"); - WriteIncrementSampleX(p); + WriteSampleColor(p, comp, "color1.g",HLSL); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, comp, "color0.r"); - WriteIncrementSampleX(p); + WriteSampleColor(p, comp, "color0.r",HLSL); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, comp, "color1.r"); - WriteIncrementSampleX(p); + WriteSampleColor(p, comp, "color1.r",HLSL); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, comp, "color0.a"); - WriteIncrementSampleX(p); + WriteSampleColor(p, comp, "color0.a",HLSL); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, comp, "color1.a"); + WriteSampleColor(p, comp, "color1.a",HLSL); WriteToBitDepth(p, 4, "color0", "color0"); WriteToBitDepth(p, 4, "color1", "color1"); @@ -496,47 +520,47 @@ void WriteC4Encoder(char* p, const char* comp) WriteEncoderEnd(p); } -void WriteC8Encoder(char* p, const char* comp) +void WriteC8Encoder(char* p, const char* comp,bool HLSL) { - WriteSwizzler(p, GX_CTF_R8); + WriteSwizzler(p, GX_CTF_R8,HLSL); - WriteSampleColor(p, comp, "ocol0.b"); - WriteIncrementSampleX(p); + WriteSampleColor(p, comp, "ocol0.b",HLSL); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, comp, "ocol0.g"); - WriteIncrementSampleX(p); + WriteSampleColor(p, comp, "ocol0.g",HLSL); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, comp, "ocol0.r"); - WriteIncrementSampleX(p); + WriteSampleColor(p, comp, "ocol0.r",HLSL); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, comp, "ocol0.a"); + WriteSampleColor(p, comp, "ocol0.a",HLSL); WriteEncoderEnd(p); } -void WriteCC4Encoder(char* p, const char* comp) +void WriteCC4Encoder(char* p, const char* comp,bool HLSL) { - WriteSwizzler(p, GX_CTF_RA4); + WriteSwizzler(p, GX_CTF_RA4,HLSL); WRITE(p, " float2 texSample;\n"); WRITE(p, " float4 color0;\n"); WRITE(p, " float4 color1;\n"); - WriteSampleColor(p, comp, "texSample"); + WriteSampleColor(p, comp, "texSample",HLSL); WRITE(p, " color0.b = texSample.x;\n"); WRITE(p, " color1.b = texSample.y;\n"); - WriteIncrementSampleX(p); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, comp, "texSample"); + WriteSampleColor(p, comp, "texSample",HLSL); WRITE(p, " color0.g = texSample.x;\n"); WRITE(p, " color1.g = texSample.y;\n"); - WriteIncrementSampleX(p); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, comp, "texSample"); + WriteSampleColor(p, comp, "texSample",HLSL); WRITE(p, " color0.r = texSample.x;\n"); WRITE(p, " color1.r = texSample.y;\n"); - WriteIncrementSampleX(p); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, comp, "texSample"); + WriteSampleColor(p, comp, "texSample",HLSL); WRITE(p, " color0.a = texSample.x;\n"); WRITE(p, " color1.a = texSample.y;\n"); @@ -547,96 +571,96 @@ void WriteCC4Encoder(char* p, const char* comp) WriteEncoderEnd(p); } -void WriteCC8Encoder(char* p, const char* comp) +void WriteCC8Encoder(char* p, const char* comp, bool HLSL) { - WriteSwizzler(p, GX_CTF_RA8); + WriteSwizzler(p, GX_CTF_RA8,HLSL); - WriteSampleColor(p, comp, "ocol0.bg"); - WriteIncrementSampleX(p); + WriteSampleColor(p, comp, "ocol0.bg",HLSL); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, comp, "ocol0.ra"); + WriteSampleColor(p, comp, "ocol0.ra",HLSL); WriteEncoderEnd(p); } -void WriteZ8Encoder(char* p, const char* multiplier) +void WriteZ8Encoder(char* p, const char* multiplier,bool HLSL) { - WriteSwizzler(p, GX_CTF_Z8M); + WriteSwizzler(p, GX_CTF_Z8M,HLSL); WRITE(p, " float depth;\n"); - WriteSampleColor(p, "b", "depth"); + WriteSampleColor(p, "b", "depth",HLSL); WRITE(p, "ocol0.b = frac(depth * %s);\n", multiplier); - WriteIncrementSampleX(p); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, "b", "depth"); + WriteSampleColor(p, "b", "depth",HLSL); WRITE(p, "ocol0.g = frac(depth * %s);\n", multiplier); - WriteIncrementSampleX(p); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, "b", "depth"); + WriteSampleColor(p, "b", "depth",HLSL); WRITE(p, "ocol0.r = frac(depth * %s);\n", multiplier); - WriteIncrementSampleX(p); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, "b", "depth"); + WriteSampleColor(p, "b", "depth",HLSL); WRITE(p, "ocol0.a = frac(depth * %s);\n", multiplier); WriteEncoderEnd(p); } -void WriteZ16Encoder(char* p) +void WriteZ16Encoder(char* p,bool HLSL) { - WriteSwizzler(p, GX_TF_Z16); + WriteSwizzler(p, GX_TF_Z16,HLSL); WRITE(p, " float depth;\n"); // byte order is reversed - WriteSampleColor(p, "b", "depth"); + WriteSampleColor(p, "b", "depth",HLSL); WRITE(p, " ocol0.b = frac(depth * 256.0f);\n"); WRITE(p, " ocol0.g = depth;\n"); - WriteIncrementSampleX(p); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, "b", "depth"); + WriteSampleColor(p, "b", "depth",HLSL); WRITE(p, " ocol0.r = frac(depth * 256.0f);\n"); WRITE(p, " ocol0.a = depth;\n"); WriteEncoderEnd(p); } -void WriteZ16LEncoder(char* p) +void WriteZ16LEncoder(char* p,bool HLSL) { - WriteSwizzler(p, GX_CTF_Z16L); + WriteSwizzler(p, GX_CTF_Z16L,HLSL); WRITE(p, " float depth;\n"); // byte order is reversed - WriteSampleColor(p, "b", "depth"); + WriteSampleColor(p, "b", "depth",HLSL); WRITE(p, " ocol0.b = frac(depth * 65536.0f);\n"); WRITE(p, " ocol0.g = frac(depth * 256.0f);\n"); - WriteIncrementSampleX(p); + WriteIncrementSampleX(p,HLSL); - WriteSampleColor(p, "b", "depth"); + WriteSampleColor(p, "b", "depth",HLSL); WRITE(p, " ocol0.r = frac(depth * 65536.0f);\n"); WRITE(p, " ocol0.a = frac(depth * 256.0f);\n"); WriteEncoderEnd(p); } -void WriteZ24Encoder(char* p) +void WriteZ24Encoder(char* p, bool HLSL) { - Write32BitSwizzler(p, GX_TF_Z24X8); + Write32BitSwizzler(p, GX_TF_Z24X8,HLSL); WRITE(p, " float cl = xb - (halfxb * 2);\n"); WRITE(p, " float depth0;\n"); WRITE(p, " float depth1;\n"); - WriteSampleColor(p, "b", "depth0"); - WriteIncrementSampleX(p); - WriteSampleColor(p, "b", "depth1"); + WriteSampleColor(p, "b", "depth0",HLSL); + WriteIncrementSampleX(p,HLSL); + WriteSampleColor(p, "b", "depth1",HLSL); WRITE(p, " if(cl > 0.5f) {\n"); // upper 16 @@ -654,7 +678,7 @@ void WriteZ24Encoder(char* p) WriteEncoderEnd(p); } -const char *GenerateEncodingShader(u32 format) +const char *GenerateEncodingShader(u32 format,bool HLSL) { setlocale(LC_NUMERIC, "C"); // Reset locale for compilation text[sizeof(text) - 1] = 0x7C; // canary @@ -664,73 +688,73 @@ const char *GenerateEncodingShader(u32 format) switch(format) { case GX_TF_I4: - WriteI4Encoder(p); + WriteI4Encoder(p,HLSL); break; case GX_TF_I8: - WriteI8Encoder(p); + WriteI8Encoder(p,HLSL); break; case GX_TF_IA4: - WriteIA4Encoder(p); + WriteIA4Encoder(p,HLSL); break; case GX_TF_IA8: - WriteIA8Encoder(p); + WriteIA8Encoder(p,HLSL); break; case GX_TF_RGB565: - WriteRGB565Encoder(p); + WriteRGB565Encoder(p,HLSL); break; case GX_TF_RGB5A3: - WriteRGB5A3Encoder(p); + WriteRGB5A3Encoder(p,HLSL); break; case GX_TF_RGBA8: - WriteRGBA8Encoder(p); + WriteRGBA8Encoder(p,HLSL); break; case GX_CTF_R4: - WriteC4Encoder(p, "r"); + WriteC4Encoder(p, "r",HLSL); break; case GX_CTF_RA4: - WriteCC4Encoder(p, "ar"); + WriteCC4Encoder(p, "ar",HLSL); break; case GX_CTF_RA8: - WriteCC8Encoder(p, "ar"); + WriteCC8Encoder(p, "ar",HLSL); break; case GX_CTF_A8: - WriteC8Encoder(p, "a"); + WriteC8Encoder(p, "a",HLSL); break; case GX_CTF_R8: - WriteC8Encoder(p, "r"); + WriteC8Encoder(p, "r",HLSL); break; case GX_CTF_G8: - WriteC8Encoder(p, "g"); + WriteC8Encoder(p, "g",HLSL); break; case GX_CTF_B8: - WriteC8Encoder(p, "b"); + WriteC8Encoder(p, "b",HLSL); break; case GX_CTF_RG8: - WriteCC8Encoder(p, "rg"); + WriteCC8Encoder(p, "rg",HLSL); break; case GX_CTF_GB8: - WriteCC8Encoder(p, "gb"); + WriteCC8Encoder(p, "gb",HLSL); break; case GX_TF_Z8: - WriteC8Encoder(p, "b"); + WriteC8Encoder(p, "b",HLSL); break; case GX_TF_Z16: - WriteZ16Encoder(p); + WriteZ16Encoder(p,HLSL); break; case GX_TF_Z24X8: - WriteZ24Encoder(p); + WriteZ24Encoder(p,HLSL); break; case GX_CTF_Z4: - WriteC4Encoder(p, "b"); + WriteC4Encoder(p, "b",HLSL); break; case GX_CTF_Z8M: - WriteZ8Encoder(p, "256.0f"); + WriteZ8Encoder(p, "256.0f",HLSL); break; case GX_CTF_Z8L: - WriteZ8Encoder(p, "65536.0f" ); + WriteZ8Encoder(p, "65536.0f" ,HLSL); break; case GX_CTF_Z16L: - WriteZ16LEncoder(p); + WriteZ16LEncoder(p,HLSL); break; default: PanicAlert("Unknown texture copy format: 0x%x\n", format); @@ -744,9 +768,9 @@ const char *GenerateEncodingShader(u32 format) return text; } -void SetShaderParameters(float width, float height, float offsetX, float offsetY, float widthStride, float heightStride) +void SetShaderParameters(float width, float height, float offsetX, float offsetY, float widthStride, float heightStride,float buffW,float buffH) { - SetPSConstant4f(C_COLORMATRIX, widthStride, heightStride, 0.0f, 0.0f); + SetPSConstant4f(C_COLORMATRIX, widthStride, heightStride, buffW, buffH); SetPSConstant4f(C_COLORMATRIX + 1, width, (height - 1), offsetX, offsetY); } diff --git a/Source/Core/VideoCommon/Src/TextureConversionShader.h b/Source/Core/VideoCommon/Src/TextureConversionShader.h index 2a8a9ff1d7..7e81c4cc4f 100644 --- a/Source/Core/VideoCommon/Src/TextureConversionShader.h +++ b/Source/Core/VideoCommon/Src/TextureConversionShader.h @@ -25,9 +25,9 @@ namespace TextureConversionShader { u16 GetEncodedSampleCount(u32 format); -const char *GenerateEncodingShader(u32 format); +const char *GenerateEncodingShader(u32 format,bool HLSL = false); -void SetShaderParameters(float width, float height, float offsetX, float offsetY, float widthStride, float heightStride); +void SetShaderParameters(float width, float height, float offsetX, float offsetY, float widthStride, float heightStride,float buffW = 0.0f,float buffH = 0.0f); } diff --git a/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcproj b/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcproj index cac85602d4..f4b0540b8f 100644 --- a/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcproj +++ b/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcproj @@ -1,7 +1,7 @@ + + + + right-rSource->left - 1.0f) * (rDest->right - rDest->left))/(SourceWidth*((rDest->right - rDest->left)-1.0f)); float u1=((float)rSource->left+1.0f)/(float) SourceWidth;//*/((0.5f+rSource->left)/(float) SourceWidth)-(span*0.5f/(float)(rDest->right - rDest->left)); float u2=((float)rSource->right-1.0f)/(float) SourceWidth;;//*/u1+span; @@ -419,6 +419,24 @@ void drawShadedTexQuad(IDirect3DTexture9 *texture, D3D::RefreshVertexDeclaration(); RestoreRenderStates(); -} +} + +void drawColoredQuad(const RECT *rDest, u32 Color) +{ + SaveRenderStates(); + struct Q2DVertex { float x,y,z,rhw;u32 Color; } coords[4] = { + {(float)rDest->left-0.5f, (float)rDest->top-0.5f, 0.0f, 1.0f, Color}, + {(float)rDest->right-0.5f, (float)rDest->top-0.5f, 0.0f,1.0f, Color}, + {(float)rDest->right-0.5f, (float)rDest->bottom-0.5f, 0.0f,1.0f, Color}, + {(float)rDest->left-0.5f, (float)rDest->bottom-0.5f, 0.0f,1.0f, Color} + }; + dev->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE); + dev->SetVertexShader(0); + dev->SetPixelShader(0); + dev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, coords, sizeof(Q2DVertex)); + D3D::RefreshVertexDeclaration(); + RestoreRenderStates(); +} + } // namespace diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.h b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.h index e61f6b06e1..6e3d61b6a0 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.h @@ -65,6 +65,7 @@ namespace D3D const RECT *rDest, IDirect3DPixelShader9 *PShader, IDirect3DVertexShader9 *Vshader); + void drawColoredQuad(const RECT *rDest, u32 Color); void SaveRenderStates(); void RestoreRenderStates(); } diff --git a/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.cpp b/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.cpp index 4fbdfec16f..6c03a290bf 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.cpp @@ -188,7 +188,7 @@ void Create() D3DMULTISAMPLE_NONE, 0, FALSE, &s_efb_depth_surface, NULL); CHECK(hr,"CreateDepthStencilSurface"); //ULTRAAAAAAAAAAA ugly hack when no depth textures are supported - s_efb_depthColor_surface = s_efb_color_surface; + //s_efb_depthColor_surface = s_efb_color_surface; } } diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp index 496d22bc85..29b7826ad6 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp @@ -41,6 +41,7 @@ #include "OnScreenDisplay.h" #include "FramebufferManager.h" #include "Fifo.h" +#include "TextureConverter.h" #include "debugger/debugger.h" @@ -97,7 +98,7 @@ void SetupDeviceObjects() VertexShaderManager::Dirty(); PixelShaderManager::Dirty(); - + TextureConverter::Init(); // Tex and shader caches will recreate themselves over time. } @@ -114,6 +115,7 @@ void TeardownDeviceObjects() VertexLoaderManager::Shutdown(); VertexShaderCache::Clear(); PixelShaderCache::Clear(); + TextureConverter::Shutdown(); } bool Renderer::Init() @@ -167,7 +169,7 @@ bool Renderer::Init() vp.Width = s_backbuffer_width; vp.Height = s_backbuffer_height; vp.MinZ = 0.0f; - vp.MaxZ = 0.0f; + vp.MaxZ = 1.0f; D3D::dev->SetViewport(&vp); D3D::dev->Clear(0, NULL, D3DCLEAR_TARGET, 0x0, 0, 0); @@ -177,8 +179,6 @@ bool Renderer::Init() D3D::dev->SetDepthStencilSurface(FBManager::GetEFBDepthRTSurface()); vp.Width = s_target_width; vp.Height = s_target_height; - vp.MinZ = 0.0f; - vp.MaxZ = 0.0f; D3D::dev->SetViewport(&vp); D3D::dev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x0, 1.0f, 0); D3D::BeginFrame(); @@ -273,12 +273,6 @@ void CheckForResize() static void EFBTextureToD3DBackBuffer(const EFBRectangle& sourceRc) { - // Set the backbuffer as the rendering target - D3D::dev->SetDepthStencilSurface(NULL); - if(D3D::GetCaps().NumSimultaneousRTs > 1) - D3D::dev->SetRenderTarget(1, NULL); - D3D::dev->SetRenderTarget(0, D3D::GetBackBufferSurface()); - TargetRectangle src_rect, dst_rect; src_rect = Renderer::ConvertEFBRectangle(sourceRc); ComputeDrawRectangle(s_backbuffer_width, s_backbuffer_height, false, &dst_rect); @@ -288,21 +282,33 @@ static void EFBTextureToD3DBackBuffer(const EFBRectangle& sourceRc) vp.Width = s_backbuffer_width; vp.Height = s_backbuffer_height; vp.MinZ = 0.0f; - vp.MaxZ = 0.0f; + vp.MaxZ = 1.0f; D3D::dev->SetViewport(&vp); D3D::dev->Clear(0,NULL, D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0f,0); - vp.X = dst_rect.left; - vp.Y = dst_rect.top; - vp.Width = dst_rect.right - dst_rect.left; - vp.Height = dst_rect.bottom - dst_rect.top; + int X = dst_rect.left; + int Y = dst_rect.top; + int Width = dst_rect.right - dst_rect.left; + int Height = dst_rect.bottom - dst_rect.top; + + if(X < 0) X = 0; + if(Y < 0) Y = 0; + if(X > s_backbuffer_width) X = s_backbuffer_width; + if(Y > s_backbuffer_height) Y = s_backbuffer_height; + if(Width < 0) Width = 0; + if(Height < 0) Height = 0; + if(Width > (s_backbuffer_width - X)) Width = s_backbuffer_width - X; + if(Height > (s_backbuffer_height - Y)) Height = s_backbuffer_height - Y; + vp.X = X; + vp.Y = Y; + vp.Width = Width; + vp.Height = Height; vp.MinZ = 0.0f; - vp.MaxZ = 0.0f; + vp.MaxZ = 1.0f; + D3D::dev->SetViewport(&vp); - EFBRectangle efbRect; - - + EFBRectangle efbRect; LPDIRECT3DTEXTURE9 read_texture = FBManager::GetEFBColorTexture(efbRect); RECT destinationrect; @@ -331,13 +337,6 @@ static void EFBTextureToD3DBackBuffer(const EFBRectangle& sourceRc) } OSD::DrawMessages(); - - D3D::dev->SetRenderTarget(0, FBManager::GetEFBColorRTSurface()); - if(D3D::GetCaps().NumSimultaneousRTs > 1) - D3D::dev->SetRenderTarget(1, FBManager::GetEFBDepthEncodedSurface()); - D3D::dev->SetDepthStencilSurface(FBManager::GetEFBDepthRTSurface()); - - VertexShaderManager::SetViewportChanged(); } @@ -414,8 +413,13 @@ void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRect DEBUGGER_PAUSE_LOG_AT(NEXT_XFB_CMD,false,{printf("RenderToXFB - disabled");}); return; } - Renderer::ResetAPIState(); + // Set the backbuffer as the rendering target + D3D::dev->SetDepthStencilSurface(NULL); + if(D3D::GetCaps().NumSimultaneousRTs > 1) + D3D::dev->SetRenderTarget(1, NULL); + D3D::dev->SetRenderTarget(0, D3D::GetBackBufferSurface()); + D3DDumpFrame(); EFBTextureToD3DBackBuffer(sourceRc); D3D::EndFrame(); @@ -433,7 +437,12 @@ void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRect // until the XFB pointer is updated by VI D3D::BeginFrame(); Renderer::RestoreAPIState(); - UpdateViewport(); + D3D::dev->SetRenderTarget(0, FBManager::GetEFBColorRTSurface()); + if(D3D::GetCaps().NumSimultaneousRTs > 1) + D3D::dev->SetRenderTarget(1, FBManager::GetEFBDepthEncodedSurface()); + D3D::dev->SetDepthStencilSurface(FBManager::GetEFBDepthRTSurface()); + UpdateViewport(); + VertexShaderManager::SetViewportChanged(); } @@ -460,20 +469,7 @@ bool Renderer::SetScissorRect() if (rc.bottom < 0) rc.bottom = 0; if (rc.top > s_target_height) rc.top = s_target_height; if (rc.bottom > s_target_height) rc.bottom = s_target_height; - /*LONG temprc = 0; - if(rc.right < rc.left) - { - temprc = rc.right; - rc.right = rc.left; - rc.left = temprc; - } - if(rc.bottom < rc.top) - { - temprc = rc.bottom; - rc.bottom = rc.top; - rc.top = temprc; - } - D3D::dev->SetScissorRect(&rc);*/ + if (rc.right >= rc.left && rc.bottom >= rc.top) { D3D::dev->SetScissorRect(&rc); @@ -482,14 +478,14 @@ bool Renderer::SetScissorRect() else { WARN_LOG(VIDEO, "Bad scissor rectangle: %i %i %i %i", rc.left, rc.top, rc.right, rc.bottom); - rc.left = 0; + /*rc.left = 0; rc.top = 0; rc.right = GetTargetWidth(); rc.bottom = GetTargetHeight(); - D3D::dev->SetScissorRect(&rc); + D3D::dev->SetScissorRect(&rc);*/ return false; } - return true; + return false; } void Renderer::SetColorMask() @@ -644,18 +640,23 @@ void UpdateViewport() D3DVIEWPORT9 vp; // Stretch picture with increased internal resolution - vp.X = (int)(ceil(xfregs.rawViewport[3] - xfregs.rawViewport[0] - (scissorXOff)) * MValueX); - vp.Y = (int)(ceil(xfregs.rawViewport[4] + xfregs.rawViewport[1] - (scissorYOff)) * MValueY); - vp.Width = (int)ceil(abs((int)(2 * xfregs.rawViewport[0])) * MValueX); - vp.Height = (int)ceil(abs((int)(2 * xfregs.rawViewport[1])) * MValueY); - if(vp.X < 0) vp.X = 0; - if(vp.Y < 0) vp.Y = 0; - if(vp.X > s_target_width) vp.X = s_target_width; - if(vp.Y > s_target_height) vp.Y = s_target_height; - if(vp.Width < 0) vp.Width = 0; - if(vp.Height < 0) vp.Height = 0; - if(vp.Width > (s_target_width - vp.X)) vp.Width = s_target_width - vp.X; - if(vp.Height > (s_target_height - vp.Y)) vp.Height = s_target_height - vp.Y; + int X = (int)(ceil(xfregs.rawViewport[3] - xfregs.rawViewport[0] - (scissorXOff)) * MValueX); + int Y = (int)(ceil(xfregs.rawViewport[4] + xfregs.rawViewport[1] - (scissorYOff)) * MValueY); + int Width = (int)ceil(abs((int)(2 * xfregs.rawViewport[0])) * MValueX); + int Height = (int)ceil(abs((int)(2 * xfregs.rawViewport[1])) * MValueY); + + if(X < 0) X = 0; + if(Y < 0) Y = 0; + if(X > s_target_width) X = s_target_width; + if(Y > s_target_height) Y = s_target_height; + if(Width < 0) Width = 0; + if(Height < 0) Height = 0; + if(Width > (s_target_width - X)) Width = s_target_width - X; + if(Height > (s_target_height - Y)) Height = s_target_height - Y; + vp.X = X; + vp.Y = Y; + vp.Width = Width; + vp.Height = Height; //some games set invalids values for z min and z max so fix them to the max an min alowed and let the shaders do this work vp.MinZ = 0.0f;//(xfregs.rawViewport[5] - xfregs.rawViewport[2]) / 16777216.0f; vp.MaxZ = 1.0f;//xfregs.rawViewport[5] / 16777216.0f; @@ -664,28 +665,6 @@ void UpdateViewport() void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z) { - // Update the view port for clearing the picture - D3DVIEWPORT9 vp; - vp.X = 0; - vp.Y = 0; - vp.Width = Renderer::GetTargetWidth(); - vp.Height = Renderer::GetTargetHeight(); - vp.MinZ = 0.0; - vp.MaxZ = 1.0; - D3D::dev->SetViewport(&vp); - - TargetRectangle targetRc = Renderer::ConvertEFBRectangle(rc); - - // Always set the scissor in case it was set by the game and has not been reset - RECT sirc; - sirc.left = targetRc.left; - sirc.top = targetRc.top; - sirc.right = targetRc.right; - sirc.bottom = targetRc.bottom; - D3D::dev->SetScissorRect(&sirc); - - VertexShaderManager::SetViewportChanged(); - DWORD clearflags = 0; if(colorEnable) { @@ -695,8 +674,31 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaE { clearflags |= D3DCLEAR_ZBUFFER; } + if(clearflags) + { + // Update the view port for clearing the picture + D3DVIEWPORT9 vp; + vp.X = 0; + vp.Y = 0; + vp.Width = Renderer::GetTargetWidth(); + vp.Height = Renderer::GetTargetHeight(); + vp.MinZ = 0.0; + vp.MaxZ = 1.0; + D3D::dev->SetViewport(&vp); - D3D::dev->Clear(0, NULL, clearflags, color,(z & 0xFFFFFF) / float(0xFFFFFF), 0); + TargetRectangle targetRc = Renderer::ConvertEFBRectangle(rc); + + // Always set the scissor in case it was set by the game and has not been reset + RECT sirc; + sirc.left = targetRc.left; + sirc.top = targetRc.top; + sirc.right = targetRc.right; + sirc.bottom = targetRc.bottom; + D3D::dev->SetScissorRect(&sirc); + D3D::dev->Clear(0, NULL, clearflags, color,(z & 0xFFFFFF) / float(0xFFFFFF), 0); + SetScissorRect(); + VertexShaderManager::SetViewportChanged(); + } } void Renderer::SetBlendMode(bool forceUpdate) diff --git a/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp index 35b3d43a7f..827df1da62 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp @@ -288,12 +288,8 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width, return &entry; } -#undef CHECK -#define CHECK(hr) if (FAILED(hr)) { PanicAlert(__FUNCTION__ " FAIL"); } -// EXTREMELY incomplete. void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle &source_rect) { - HRESULT hr = S_OK; int efb_w = source_rect.GetWidth(); int efb_h = source_rect.GetHeight(); @@ -330,8 +326,7 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo entry.h = tex_h; entry.fmt = copyfmt; - hr = D3D::dev->CreateTexture(tex_w, tex_h, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &entry.texture, 0); - CHECK(hr); + D3D::dev->CreateTexture(tex_w, tex_h, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &entry.texture, 0); textures[address] = entry; tex = entry.texture; } @@ -451,8 +446,7 @@ have_texture: // We have to run a pixel shader, for color conversion. Renderer::ResetAPIState(); // reset any game specific settings LPDIRECT3DSURFACE9 Rendersurf = NULL; - hr = tex->GetSurfaceLevel(0,&Rendersurf); - CHECK(hr); + tex->GetSurfaceLevel(0,&Rendersurf); D3D::dev->SetDepthStencilSurface(NULL); if(D3D::GetCaps().NumSimultaneousRTs > 1) D3D::dev->SetRenderTarget(1, NULL); @@ -467,8 +461,7 @@ have_texture: vp.Height = tex_h; vp.MinZ = 0.0f; vp.MaxZ = 1.0f; - hr = D3D::dev->SetViewport(&vp); - CHECK(hr); + D3D::dev->SetViewport(&vp); RECT destrect; destrect.bottom = tex_h; destrect.left = 0;