diff options
| author | Rodolfo Osvaldo Bogado <rodolfoosvaldobogado@gmail.com> | 2010-06-14 14:36:01 +0000 |
|---|---|---|
| committer | Rodolfo Osvaldo Bogado <rodolfoosvaldobogado@gmail.com> | 2010-06-14 14:36:01 +0000 |
| commit | fc12291806c5f6eb6ba06f0f533d8723808bd129 (patch) | |
| tree | 50b5eb960024b215ea610230af73b80177a5068f /Source/Core/VideoCommon | |
| parent | ff50fd188fa82004bea7550fbf1b78903254190d (diff) | |
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
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/Src/PixelShaderGen.cpp | 91 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/PixelShaderGen.h | 2 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/VertexShaderGen.h | 2 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/VideoCommon.h | 7 |
4 files changed, 86 insertions, 16 deletions
diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index ae2758c84f..afc1400c3a 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -385,10 +385,18 @@ const char *GeneratePixelShaderCode(u32 texture_mask, bool dstAlphaEnable, API_ // Declare samplers if (texture_mask) { - if (ApiType != API_OPENGL) + if (ApiType == API_D3D11) + { + WRITE(p, "sampler "); + } + else if (ApiType == API_D3D9) + { WRITE(p, "uniform sampler "); + } else + { WRITE(p, "uniform samplerRECT "); + } bool bfirst = true; for (int i = 0; i < 8; ++i) { @@ -398,19 +406,57 @@ const char *GeneratePixelShaderCode(u32 texture_mask, bool dstAlphaEnable, API_ bfirst = false; } } - WRITE(p, ";\n"); + WRITE(p, ";\n"); + if(ApiType == API_D3D11) + { + bfirst = true; + WRITE(p, "Texture2D "); + for (int i = 0; i < 8; ++i) + { + if (texture_mask & (1<<i)) + { + WRITE(p, "%s Tex%d : register(t%d)", bfirst?"":",", i, i); + bfirst = false; + } + } + WRITE(p, ";\n"); + } } - if (texture_mask != 0xff) { - WRITE(p, "uniform sampler2D "); - bool bfirst = true; - for (int i = 0; i < 8; ++i) { + if (texture_mask != 0xff) + { + if(ApiType != API_D3D11) + { + WRITE(p, "uniform sampler2D "); + } + else + { + WRITE(p, "sampler "); + } + + bool bfirst = true; + for (int i = 0; i < 8; ++i) + { if (!(texture_mask & (1<<i))) { WRITE(p, "%s samp%d : register(s%d)", bfirst?"":",",i, i); bfirst = false; } } WRITE(p, ";\n"); + if(ApiType == API_D3D11) + { + WRITE(p, "Texture2D "); + bfirst = true; + for (int i = 0; i < 8; ++i) + { + if (!(texture_mask & (1<<i))) + { + WRITE(p, "%s Tex%d : register(t%d)", bfirst?"":",", i, i); + bfirst = false; + } + } + WRITE(p, ";\n"); + } } WRITE(p, "\n"); @@ -425,9 +471,20 @@ const char *GeneratePixelShaderCode(u32 texture_mask, bool dstAlphaEnable, API_ WRITE(p, "uniform float4 "I_FOG"[2] : register(c%d);\n", C_FOG); WRITE(p, "void main(\n"); - WRITE(p, " out float4 ocol0 : COLOR0,\n"); - WRITE(p, " out float depth : DEPTH,\n"); - WRITE(p, " in float4 rawpos : POSITION,\n"); + if(ApiType != API_D3D11) + WRITE(p, " out float4 ocol0 : COLOR0,\n"); + else + WRITE(p, " out float4 ocol0 : SV_Target,\n"); + + if(ApiType != API_D3D11) + WRITE(p, " out float depth : DEPTH,\n"); + else + WRITE(p, " out float depth : SV_Depth,\n"); + if(ApiType != API_D3D11) + WRITE(p, " in float4 rawpos : POSITION,\n"); + else + WRITE(p, " in float4 rawpos : SV_Position,\n"); + WRITE(p, " in float4 colors_0 : COLOR0,\n"); WRITE(p, " in float4 colors_1 : COLOR1\n"); @@ -449,7 +506,7 @@ const char *GeneratePixelShaderCode(u32 texture_mask, bool dstAlphaEnable, API_ char* pmainstart = p; - WRITE(p, " float4 c0="I_COLORS"[1],c1="I_COLORS"[2],c2="I_COLORS"[3],prev=float4(0.0f,0.0f,0.0f,0.0f),textemp,rastemp,konsttemp=float4(0.0f,0.0f,0.0f,0.0f);\n" + WRITE(p, " float4 c0="I_COLORS"[1],c1="I_COLORS"[2],c2="I_COLORS"[3],prev=float4(0.0f,0.0f,0.0f,0.0f),textemp=float4(0.0f,0.0f,0.0f,0.0f),rastemp=float4(0.0f,0.0f,0.0f,0.0f),konsttemp=float4(0.0f,0.0f,0.0f,0.0f);\n" " float3 comp16 = float3(1.0f,255.0f,0.0f), comp24 = float3(1.0f,255.0f,255.0f*255.0f);\n" " float4 alphabump=0;\n" " float3 tevcoord;\n" @@ -874,21 +931,27 @@ void SampleTexture(char *&p, const char *destination, const char *texcoords, con else { WRITE(p, "tempcoord.y = %s.y;\n", texcoords); } - - if (ApiType != API_OPENGL) + if (ApiType == API_D3D11) + WRITE(p, "%s= Tex%d.Sample(samp%d,tempcoord.xy).%s;\n", destination, texmap,texmap, texswap); + else if (ApiType == API_D3D9) WRITE(p, "%s=tex2D(samp%d,tempcoord.xy).%s;\n", destination, texmap, texswap); else WRITE(p, "%s=texRECT(samp%d,tempcoord.xy).%s;\n", destination, texmap, texswap); } else { - if (ApiType != API_OPENGL) + if (ApiType == API_D3D11) + WRITE(p, "%s=Tex%d.Sample(samp%d,%s.xy).%s;\n", destination,texmap,texmap, texcoords, texswap); + else if (ApiType == API_D3D9) WRITE(p, "%s=tex2D(samp%d,%s.xy).%s;\n", destination, texmap, texcoords, texswap); else WRITE(p, "%s=texRECT(samp%d,%s.xy).%s;\n", destination, texmap, texcoords, texswap); } } else { - WRITE(p, "%s=tex2D(samp%d,%s.xy * "I_TEXDIMS"[%d].xy).%s;\n", destination, texmap, texcoords, texmap, texswap); + if (ApiType == API_D3D11) + WRITE(p, "%s=Tex%d.Sample(samp%d,%s.xy * "I_TEXDIMS"[%d].xy).%s;\n", destination, texmap,texmap, texcoords, texmap, texswap); + else + WRITE(p, "%s=tex2D(samp%d,%s.xy * "I_TEXDIMS"[%d].xy).%s;\n", destination, texmap, texcoords, texmap, texswap); } } diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.h b/Source/Core/VideoCommon/Src/PixelShaderGen.h index b2643793f7..06c4e164d7 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.h +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.h @@ -18,7 +18,7 @@ #ifndef GCOGL_PIXELSHADER_H #define GCOGL_PIXELSHADER_H -#include "Common.h" +#include "VideoCommon.h" #define I_COLORS "color" #define I_KCOLORS "k" diff --git a/Source/Core/VideoCommon/Src/VertexShaderGen.h b/Source/Core/VideoCommon/Src/VertexShaderGen.h index b22347b62e..0ca2ea181f 100644 --- a/Source/Core/VideoCommon/Src/VertexShaderGen.h +++ b/Source/Core/VideoCommon/Src/VertexShaderGen.h @@ -19,7 +19,7 @@ #define GCOGL_VERTEXSHADER_H #include "XFMemory.h" -#include "Common.h" +#include "VideoCommon.h" #define SHADER_POSMTX_ATTRIB 1 #define SHADER_NORM1_ATTRIB 6 diff --git a/Source/Core/VideoCommon/Src/VideoCommon.h b/Source/Core/VideoCommon/Src/VideoCommon.h index 9e800f887e..b215da112d 100644 --- a/Source/Core/VideoCommon/Src/VideoCommon.h +++ b/Source/Core/VideoCommon/Src/VideoCommon.h @@ -144,4 +144,11 @@ struct TargetRectangle : public MathUtil::Rectangle<int> bool IsD3D(); +typedef enum +{ + API_OPENGL, + API_D3D9, + API_D3D11 +} API_TYPE; + #endif // _VIDEOCOMMON_H |
