mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
Roll back r3833 for render targets but keep it for static textures. Most mirroring issues are OK and we shouldn't see any slowdown.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3844 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -28,7 +28,7 @@
|
||||
// a unique identifier, basically containing all the bits. Yup, it's a lot ....
|
||||
// It would likely be a lot more efficient to build this incrementally as the attributes
|
||||
// are set...
|
||||
void GetPixelShaderId(PIXELSHADERUID &uid, u32 dstAlphaEnable)
|
||||
void GetPixelShaderId(PIXELSHADERUID &uid, u32 s_texturemask, u32 dstAlphaEnable)
|
||||
{
|
||||
u32 projtexcoords = 0;
|
||||
for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages + 1; i++) {
|
||||
@ -51,7 +51,7 @@ void GetPixelShaderId(PIXELSHADERUID &uid, u32 dstAlphaEnable)
|
||||
for (int i = 0; i < 8; i += 2)
|
||||
((u8*)&uid.values[1])[i/2] = (bpmem.tevksel[i].hex & 0xf) | ((bpmem.tevksel[i + 1].hex & 0xf) << 4);
|
||||
|
||||
uid.values[2] = 0;
|
||||
uid.values[2] = s_texturemask;
|
||||
|
||||
uid.values[3] = (u32)bpmem.fog.c_proj_fsel.fsel |
|
||||
((u32)bpmem.fog.c_proj_fsel.proj << 3);
|
||||
@ -130,8 +130,8 @@ void GetPixelShaderId(PIXELSHADERUID &uid, u32 dstAlphaEnable)
|
||||
// output is given by .outreg
|
||||
// tevtemp is set according to swapmodetables and
|
||||
|
||||
static void WriteStage(char *&p, int n);
|
||||
static void SampleTexture(char *&p, const char *destination, const char *texcoords, const char *texswap, int texmap);
|
||||
static void WriteStage(char *&p, int n, u32 texture_mask);
|
||||
static void SampleTexture(char *&p, const char *destination, const char *texcoords, const char *texswap, int texmap, u32 texture_mask);
|
||||
static void WriteAlphaCompare(char *&p, int num, int comp);
|
||||
static bool WriteAlphaTest(char *&p, bool HLSL);
|
||||
static void WriteFog(char *&p);
|
||||
@ -368,7 +368,7 @@ static void BuildSwapModeTable()
|
||||
}
|
||||
}
|
||||
|
||||
const char *GeneratePixelShader(bool dstAlphaEnable, bool HLSL)
|
||||
const char *GeneratePixelShader(u32 texture_mask, bool dstAlphaEnable, bool HLSL)
|
||||
{
|
||||
text[sizeof(text) - 1] = 0x7C; // canary
|
||||
DVSTARTPROFILE();
|
||||
@ -391,13 +391,30 @@ const char *GeneratePixelShader(bool dstAlphaEnable, bool HLSL)
|
||||
}
|
||||
}
|
||||
|
||||
WRITE(p, "uniform sampler2D ");
|
||||
bool bfirst = true;
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
WRITE(p, "%s samp%d : register(s%d)", bfirst ? "" : ",",i, i);
|
||||
bfirst = false;
|
||||
// Declare samplers
|
||||
if (texture_mask) {
|
||||
WRITE(p, "uniform samplerRECT ");
|
||||
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 (texture_mask != 0xff) {
|
||||
WRITE(p, "uniform sampler2D ");
|
||||
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");
|
||||
}
|
||||
WRITE(p, ";\n");
|
||||
|
||||
WRITE(p, "\n");
|
||||
|
||||
@ -459,7 +476,7 @@ const char *GeneratePixelShader(bool dstAlphaEnable, bool HLSL)
|
||||
|
||||
char buffer[32];
|
||||
sprintf(buffer, "float3 indtex%d", i);
|
||||
SampleTexture(p, buffer, "tempcoord", "abg", bpmem.tevindref.getTexMap(i));
|
||||
SampleTexture(p, buffer, "tempcoord", "abg", bpmem.tevindref.getTexMap(i), texture_mask);
|
||||
}
|
||||
}
|
||||
|
||||
@ -469,7 +486,7 @@ const char *GeneratePixelShader(bool dstAlphaEnable, bool HLSL)
|
||||
}
|
||||
|
||||
for (int i = 0; i < numStages; i++)
|
||||
WriteStage(p, i); //build the equation for this stage
|
||||
WriteStage(p, i, texture_mask); //build the equation for this stage
|
||||
|
||||
if (numTexgen >= 7) {
|
||||
WRITE(p, "float4 clipPos = float4(uv0.w, uv1.w, uv2.w, uv3.w);\n");
|
||||
@ -512,7 +529,7 @@ const char *GeneratePixelShader(bool dstAlphaEnable, bool HLSL)
|
||||
return text;
|
||||
}
|
||||
|
||||
static void WriteStage(char *&p, int n)
|
||||
static void WriteStage(char *&p, int n, u32 texture_mask)
|
||||
{
|
||||
char *rasswap = swapModeTable[bpmem.combiners[n].alphaC.rswap];
|
||||
char *texswap = swapModeTable[bpmem.combiners[n].alphaC.tswap];
|
||||
@ -612,7 +629,7 @@ static void WriteStage(char *&p, int n)
|
||||
}
|
||||
}
|
||||
|
||||
WRITE(p, "rastemp=%s.%s;\n", tevRasTable[bpmem.tevorders[n / 2].getColorChan(n & 1)], rasswap);
|
||||
WRITE(p, "rastemp=%s.%s;\n", tevRasTable[bpmem.tevorders[n / 2].getColorChan(n & 1)],rasswap);
|
||||
|
||||
if (bpmem.tevorders[n/2].getEnable(n&1)) {
|
||||
int texmap = bpmem.tevorders[n/2].getTexMap(n&1);
|
||||
@ -625,7 +642,7 @@ static void WriteStage(char *&p, int n)
|
||||
}
|
||||
}
|
||||
|
||||
SampleTexture(p, "textemp", "tevcoord", texswap, texmap);
|
||||
SampleTexture(p, "textemp", "tevcoord", texswap, texmap, texture_mask);
|
||||
}
|
||||
else
|
||||
WRITE(p, "textemp=float4(1,1,1,1);\n");
|
||||
@ -732,9 +749,37 @@ static void WriteStage(char *&p, int n)
|
||||
WRITE(p, "\n");
|
||||
}
|
||||
|
||||
void SampleTexture(char *&p, const char *destination, const char *texcoords, const char *texswap, int texmap)
|
||||
void SampleTexture(char *&p, const char *destination, const char *texcoords, const char *texswap, int texmap, u32 texture_mask)
|
||||
{
|
||||
WRITE(p, "%s=tex2D(samp%d,%s.xy * "I_TEXDIMS"[%d].xy).%s;\n", destination, texmap, texcoords, texmap, texswap);
|
||||
if (texture_mask & (1<<texmap)) {
|
||||
// non pow 2
|
||||
bool bwraps = (texture_mask & (0x100<<texmap)) ? true : false;
|
||||
bool bwrapt = (texture_mask & (0x10000<<texmap)) ? true : false;
|
||||
|
||||
if (bwraps || bwrapt) {
|
||||
if (bwraps) {
|
||||
WRITE(p, "tempcoord.x = fmod(%s.x, "I_TEXDIMS"[%d].x);\n", texcoords, texmap);
|
||||
}
|
||||
else {
|
||||
WRITE(p, "tempcoord.x = %s.x;\n", texcoords);
|
||||
}
|
||||
|
||||
if (bwrapt) {
|
||||
WRITE(p, "tempcoord.y = fmod(%s.y, "I_TEXDIMS"[%d].y);\n", texcoords, texmap);
|
||||
}
|
||||
else {
|
||||
WRITE(p, "tempcoord.y = %s.y;\n", texcoords);
|
||||
}
|
||||
|
||||
WRITE(p, "%s=texRECT(samp%d,tempcoord.xy).%s;\n", destination, texmap, 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);
|
||||
}
|
||||
}
|
||||
|
||||
static void WriteAlphaCompare(char *&p, int num, int comp)
|
||||
|
Reference in New Issue
Block a user