mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
HUGE commit :)
in general cleanup and bugfix disable pierre patch for the moment as it causes problem in some games and hopefully fix the remaining missing textures for nvidia users in opengl. make the code in pixelshadergen looks nice and readable. D3D: this is a ultra experimental commit please check for regressions or error. make the efb Scale / super sampling level customizable to improve the output quality and let the user configure quality according to his hardware. is everyone likes this change will translate it to opengl please test git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5612 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -148,10 +148,15 @@ void Enumerate()
|
||||
bool isNvidia = a.ident.VendorId == VENDOR_NVIDIA;
|
||||
|
||||
// Add SuperSamples modes
|
||||
a.aa_levels.push_back(AALevel("None", D3DMULTISAMPLE_NONE, 0));
|
||||
a.aa_levels.push_back(AALevel("2.25x SSAA", D3DMULTISAMPLE_NONE, 0));
|
||||
a.aa_levels.push_back(AALevel("4x SSAA", D3DMULTISAMPLE_NONE, 0));
|
||||
a.aa_levels.push_back(AALevel("9x SSAA", D3DMULTISAMPLE_NONE, 0));
|
||||
a.aa_levels.push_back(AALevel("1x EFB - SSAA NONE", D3DMULTISAMPLE_NONE, 0));
|
||||
a.aa_levels.push_back(AALevel("1x EFB - 4x SSAA", D3DMULTISAMPLE_NONE, 0));
|
||||
a.aa_levels.push_back(AALevel("1x EFB - 9x SSAA", D3DMULTISAMPLE_NONE, 0));
|
||||
a.aa_levels.push_back(AALevel("2x EFB - SSAA NONE", D3DMULTISAMPLE_NONE, 0));
|
||||
a.aa_levels.push_back(AALevel("2x EFB - 4x SSAA", D3DMULTISAMPLE_NONE, 0));
|
||||
a.aa_levels.push_back(AALevel("2x EFB - 9x SSAA", D3DMULTISAMPLE_NONE, 0));
|
||||
a.aa_levels.push_back(AALevel("3x EFB - SSAA NONE", D3DMULTISAMPLE_NONE, 0));
|
||||
a.aa_levels.push_back(AALevel("3x EFB - 4x SSAA", D3DMULTISAMPLE_NONE, 0));
|
||||
a.aa_levels.push_back(AALevel("3x EFB - 9x SSAA", D3DMULTISAMPLE_NONE, 0));
|
||||
//Add multisample modes
|
||||
//disable them will they are not implemnted
|
||||
/*
|
||||
|
@ -325,31 +325,12 @@ void FramebufferManager::copyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight
|
||||
float SuperSampleCompensation = 1.0f;
|
||||
float scaleX = Renderer::GetXFBScaleX();
|
||||
float scaleY = Renderer::GetXFBScaleY();
|
||||
if(g_ActiveConfig.iMultisampleMode > 0 && g_ActiveConfig.iMultisampleMode < 4)
|
||||
{
|
||||
switch (g_ActiveConfig.iMultisampleMode)
|
||||
{
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
SuperSampleCompensation = 0.5f;
|
||||
break;
|
||||
case 3:
|
||||
SuperSampleCompensation = 1.0f/3.0f;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
scaleX *= SuperSampleCompensation ;
|
||||
scaleY *= SuperSampleCompensation;
|
||||
TargetRectangle targetSource,efbSource;
|
||||
efbSource = Renderer::ConvertEFBRectangle(sourceRc);
|
||||
targetSource.top = (sourceRc.top *scaleY);
|
||||
targetSource.bottom = (sourceRc.bottom *scaleY);
|
||||
targetSource.left = (sourceRc.left *scaleX);
|
||||
targetSource.right = (sourceRc.right * scaleX);
|
||||
targetSource.top = (int)(sourceRc.top *scaleY);
|
||||
targetSource.bottom = (int)(sourceRc.bottom *scaleY);
|
||||
targetSource.left = (int)(sourceRc.left *scaleX);
|
||||
targetSource.right = (int)(sourceRc.right * scaleX);
|
||||
int target_width = targetSource.right - targetSource.left;
|
||||
int target_height = targetSource.bottom - targetSource.top;
|
||||
if (it != m_virtualXFBList.end())
|
||||
@ -445,7 +426,6 @@ void FramebufferManager::copyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight
|
||||
D3D::ChangeSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
|
||||
|
||||
|
||||
int SSAAMode = ( g_ActiveConfig.iMultisampleMode > 3 )? 0 : g_ActiveConfig.iMultisampleMode;
|
||||
D3D::drawShadedTexQuad(
|
||||
read_texture,
|
||||
&sourcerect,
|
||||
@ -453,8 +433,8 @@ void FramebufferManager::copyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight
|
||||
Renderer::GetFullTargetHeight(),
|
||||
target_width,
|
||||
target_height,
|
||||
PixelShaderCache::GetColorCopyProgram(SSAAMode),
|
||||
(SSAAMode != 0)? VertexShaderCache::GetFSAAVertexShader() : VertexShaderCache::GetSimpleVertexShader());
|
||||
PixelShaderCache::GetColorCopyProgram( g_ActiveConfig.iMultisampleMode),
|
||||
VertexShaderCache::GetSimpleVertexShader( g_ActiveConfig.iMultisampleMode));
|
||||
|
||||
|
||||
D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER);
|
||||
|
@ -42,26 +42,26 @@ LinearDiskCache g_ps_disk_cache;
|
||||
|
||||
static float lastPSconstants[C_COLORMATRIX+16][4];
|
||||
|
||||
static LPDIRECT3DPIXELSHADER9 s_ColorMatrixProgram[4];
|
||||
static LPDIRECT3DPIXELSHADER9 s_ColorCopyProgram[4];
|
||||
static LPDIRECT3DPIXELSHADER9 s_DepthMatrixProgram[4];
|
||||
static LPDIRECT3DPIXELSHADER9 s_ColorMatrixProgram[3];
|
||||
static LPDIRECT3DPIXELSHADER9 s_ColorCopyProgram[3];
|
||||
static LPDIRECT3DPIXELSHADER9 s_DepthMatrixProgram[3];
|
||||
static LPDIRECT3DPIXELSHADER9 s_ClearProgram = 0;
|
||||
|
||||
|
||||
|
||||
LPDIRECT3DPIXELSHADER9 PixelShaderCache::GetColorMatrixProgram(int SSAAMode)
|
||||
{
|
||||
return s_ColorMatrixProgram[SSAAMode];
|
||||
return s_ColorMatrixProgram[SSAAMode % 3];
|
||||
}
|
||||
|
||||
LPDIRECT3DPIXELSHADER9 PixelShaderCache::GetDepthMatrixProgram(int SSAAMode)
|
||||
{
|
||||
return s_DepthMatrixProgram[SSAAMode];
|
||||
return s_DepthMatrixProgram[SSAAMode % 3];
|
||||
}
|
||||
|
||||
LPDIRECT3DPIXELSHADER9 PixelShaderCache::GetColorCopyProgram(int SSAAMode)
|
||||
{
|
||||
return s_ColorCopyProgram[SSAAMode];
|
||||
return s_ColorCopyProgram[SSAAMode % 3];
|
||||
}
|
||||
|
||||
LPDIRECT3DPIXELSHADER9 PixelShaderCache::GetClearProgram()
|
||||
@ -132,18 +132,7 @@ void PixelShaderCache::Init()
|
||||
"in float2 uv0 : TEXCOORD0){\n"
|
||||
"ocol0 = tex2D(samp0,uv0);\n"
|
||||
"}\n");
|
||||
s_ColorCopyProgram[0] = D3D::CompileAndCreatePixelShader(pprog, (int)strlen(pprog));
|
||||
|
||||
//2 samples
|
||||
sprintf(pprog, "uniform sampler samp0 : register(s0);\n"
|
||||
"void main(\n"
|
||||
"out float4 ocol0 : COLOR0,\n"
|
||||
"in float4 uv0 : TEXCOORD0,\n"
|
||||
"in float4 uv1 : TEXCOORD1,\n"
|
||||
"in float4 uv2 : TEXCOORD2){\n"
|
||||
"ocol0 = (tex2D(samp0,uv1.xy) + tex2D(samp0,uv2.xy))*0.5f;\n"
|
||||
"}\n");
|
||||
s_ColorCopyProgram[1] = D3D::CompileAndCreatePixelShader(pprog, (int)strlen(pprog));
|
||||
s_ColorCopyProgram[0] = D3D::CompileAndCreatePixelShader(pprog, (int)strlen(pprog));
|
||||
|
||||
//4 Samples
|
||||
sprintf(pprog, "uniform sampler samp0 : register(s0);\n"
|
||||
@ -156,7 +145,7 @@ void PixelShaderCache::Init()
|
||||
"in float4 uv4 : TEXCOORD4){\n"
|
||||
"ocol0 = (tex2D(samp0,uv1.xy) + tex2D(samp0,uv2.xy) + tex2D(samp0,uv3.xy) + tex2D(samp0,uv4.xy))*0.25f;\n"
|
||||
"}\n");
|
||||
s_ColorCopyProgram[2] = D3D::CompileAndCreatePixelShader(pprog, (int)strlen(pprog));
|
||||
s_ColorCopyProgram[1] = D3D::CompileAndCreatePixelShader(pprog, (int)strlen(pprog));
|
||||
|
||||
//9 Samples
|
||||
sprintf(pprog, "uniform sampler samp0 : register(s0);\n"
|
||||
@ -169,7 +158,7 @@ void PixelShaderCache::Init()
|
||||
"in float4 uv4 : TEXCOORD4){\n"
|
||||
"ocol0 = (tex2D(samp0,uv1.xy) + tex2D(samp0,uv1.wz) + tex2D(samp0,uv2.xy) + tex2D(samp0,uv2.wz) + tex2D(samp0,uv3.xy) + tex2D(samp0,uv3.wz) + tex2D(samp0,uv4.xy) + tex2D(samp0,uv4.wz) + tex2D(samp0,uv0.xy))/9.0f;\n"
|
||||
"}\n");
|
||||
s_ColorCopyProgram[3] = D3D::CompileAndCreatePixelShader(pprog, (int)strlen(pprog));
|
||||
s_ColorCopyProgram[2] = D3D::CompileAndCreatePixelShader(pprog, (int)strlen(pprog));
|
||||
|
||||
//Color conversion Programs
|
||||
//1 sample
|
||||
@ -181,24 +170,8 @@ void PixelShaderCache::Init()
|
||||
"float4 texcol = tex2D(samp0,uv0);\n"
|
||||
"ocol0 = float4(dot(texcol,cColMatrix[0]),dot(texcol,cColMatrix[1]),dot(texcol,cColMatrix[2]),dot(texcol,cColMatrix[3])) + cColMatrix[4];\n"
|
||||
"}\n",C_COLORMATRIX);
|
||||
s_ColorMatrixProgram[0] = D3D::CompileAndCreatePixelShader(pprog, (int)strlen(pprog));
|
||||
s_ColorMatrixProgram[0] = D3D::CompileAndCreatePixelShader(pprog, (int)strlen(pprog));
|
||||
|
||||
//2 samples
|
||||
sprintf(pprog, "uniform sampler samp0 : register(s0);\n"
|
||||
"uniform float4 cColMatrix[5] : register(c%d);\n"
|
||||
"void main(\n"
|
||||
"out float4 ocol0 : COLOR0,\n"
|
||||
"in float4 uv0 : TEXCOORD0,\n"
|
||||
"in float4 uv1 : TEXCOORD1,\n"
|
||||
"in float4 uv2 : TEXCOORD2,\n"
|
||||
"in float4 uv3 : TEXCOORD3,\n"
|
||||
"in float4 uv4 : TEXCOORD4,\n"
|
||||
"in float4 uv5 : TEXCOORD5){\n"
|
||||
"float4 texcol = (tex2D(samp0,float2(clamp(uv1.x,uv5.x,uv5.z),clamp(uv1.y,uv5.y,uv5.w))) + tex2D(samp0,float2(clamp(uv2.x,uv5.x,uv5.z),clamp(uv2.y,uv5.y,uv5.w)))) * 0.5f;\n"
|
||||
"ocol0 = float4(dot(texcol,cColMatrix[0]),dot(texcol,cColMatrix[1]),dot(texcol,cColMatrix[2]),dot(texcol,cColMatrix[3])) + cColMatrix[4];\n"
|
||||
"}\n",C_COLORMATRIX);
|
||||
s_ColorMatrixProgram[1] = D3D::CompileAndCreatePixelShader(pprog, (int)strlen(pprog));
|
||||
|
||||
//4 samples
|
||||
sprintf(pprog, "uniform sampler samp0 : register(s0);\n"
|
||||
"uniform float4 cColMatrix[5] : register(c%d);\n"
|
||||
@ -213,7 +186,7 @@ void PixelShaderCache::Init()
|
||||
"float4 texcol = (tex2D(samp0,float2(clamp(uv1.x,uv5.x,uv5.z),clamp(uv1.y,uv5.y,uv5.w))) + tex2D(samp0,float2(clamp(uv2.x,uv5.x,uv5.z),clamp(uv2.y,uv5.y,uv5.w))) + tex2D(samp0,float2(clamp(uv3.x,uv5.x,uv5.z),clamp(uv3.y,uv5.y,uv5.w))) + tex2D(samp0,float2(clamp(uv4.x,uv5.x,uv5.z),clamp(uv4.y,uv5.y,uv5.w))))*0.25f;\n"
|
||||
"ocol0 = float4(dot(texcol,cColMatrix[0]),dot(texcol,cColMatrix[1]),dot(texcol,cColMatrix[2]),dot(texcol,cColMatrix[3])) + cColMatrix[4];\n"
|
||||
"}\n",C_COLORMATRIX);
|
||||
s_ColorMatrixProgram[2] = D3D::CompileAndCreatePixelShader(pprog, (int)strlen(pprog));
|
||||
s_ColorMatrixProgram[1] = D3D::CompileAndCreatePixelShader(pprog, (int)strlen(pprog));
|
||||
|
||||
//9 samples
|
||||
sprintf(pprog, "uniform sampler samp0 : register(s0);\n"
|
||||
@ -229,7 +202,7 @@ void PixelShaderCache::Init()
|
||||
"float4 texcol = (tex2D(samp0,float2(clamp(uv1.x,uv5.x,uv5.z),clamp(uv1.y,uv5.y,uv5.w))) + tex2D(samp0,float2(clamp(uv1.w,uv5.x,uv5.z),clamp(uv1.z,uv5.y,uv5.w))) + tex2D(samp0,float2(clamp(uv2.x,uv5.x,uv5.z),clamp(uv2.y,uv5.y,uv5.w))) + tex2D(samp0,float2(clamp(uv2.w,uv5.x,uv5.z),clamp(uv2.z,uv5.y,uv5.w))) + tex2D(samp0,float2(clamp(uv3.x,uv5.x,uv5.z),clamp(uv3.y,uv5.y,uv5.w))) + tex2D(samp0,float2(clamp(uv3.w,uv5.x,uv5.z),clamp(uv3.z,uv5.y,uv5.w))) + tex2D(samp0,float2(clamp(uv4.x,uv5.x,uv5.z),clamp(uv4.y,uv5.y,uv5.w))) + tex2D(samp0,float2(clamp(uv4.w,uv5.x,uv5.z),clamp(uv4.z,uv5.y,uv5.w))) + tex2D(samp0,float2(clamp(uv0.x,uv5.x,uv5.z),clamp(uv0.y,uv5.y,uv5.w))))/9;\n"
|
||||
"ocol0 = float4(dot(texcol,cColMatrix[0]),dot(texcol,cColMatrix[1]),dot(texcol,cColMatrix[2]),dot(texcol,cColMatrix[3])) + cColMatrix[4];\n"
|
||||
"}\n",C_COLORMATRIX);
|
||||
s_ColorMatrixProgram[3] = D3D::CompileAndCreatePixelShader(pprog, (int)strlen(pprog));
|
||||
s_ColorMatrixProgram[2] = D3D::CompileAndCreatePixelShader(pprog, (int)strlen(pprog));
|
||||
|
||||
//Depth copy programs
|
||||
//1 sample
|
||||
@ -243,26 +216,8 @@ void PixelShaderCache::Init()
|
||||
"texcol = float4((EncodedDepth.rgb * (16777216.0f/16777215.0f)),1.0f);\n"
|
||||
"ocol0 = float4(dot(texcol,cColMatrix[0]),dot(texcol,cColMatrix[1]),dot(texcol,cColMatrix[2]),dot(texcol,cColMatrix[3])) + cColMatrix[4];\n"
|
||||
"}\n",C_COLORMATRIX);
|
||||
s_DepthMatrixProgram[0] = D3D::CompileAndCreatePixelShader(pprog, (int)strlen(pprog));
|
||||
s_DepthMatrixProgram[0] = D3D::CompileAndCreatePixelShader(pprog, (int)strlen(pprog));
|
||||
|
||||
//2 sample
|
||||
sprintf(pprog, "uniform sampler samp0 : register(s0);\n"
|
||||
"uniform float4 cColMatrix[5] : register(c%d);\n"
|
||||
"void main(\n"
|
||||
"out float4 ocol0 : COLOR0,\n"
|
||||
"in float4 uv0 : TEXCOORD0,\n"
|
||||
"in float4 uv1 : TEXCOORD1,\n"
|
||||
"in float4 uv2 : TEXCOORD2,\n"
|
||||
"in float4 uv3 : TEXCOORD3,\n"
|
||||
"in float4 uv4 : TEXCOORD4,\n"
|
||||
"in float4 uv5 : TEXCOORD5){\n"
|
||||
"float4 texcol = (tex2D(samp0,float2(clamp(uv1.x,uv5.x,uv5.z),clamp(uv1.y,uv5.y,uv5.w))) + tex2D(samp0,float2(clamp(uv2.x,uv5.x,uv5.z),clamp(uv2.y,uv5.y,uv5.w)))) * 0.5f;\n"
|
||||
"float4 EncodedDepth = frac((texcol.r * (16777215.0f/16777216.0f)) * float4(1.0f,255.0f,255.0f*255.0f,255.0f*255.0f*255.0f));\n"
|
||||
"texcol = float4((EncodedDepth.rgb * (16777216.0f/16777215.0f)),1.0f);\n"
|
||||
"ocol0 = float4(dot(texcol,cColMatrix[0]),dot(texcol,cColMatrix[1]),dot(texcol,cColMatrix[2]),dot(texcol,cColMatrix[3])) + cColMatrix[4];\n"
|
||||
"}\n",C_COLORMATRIX);
|
||||
s_DepthMatrixProgram[1] = D3D::CompileAndCreatePixelShader(pprog, (int)strlen(pprog));
|
||||
|
||||
//4 sample
|
||||
sprintf(pprog, "uniform sampler samp0 : register(s0);\n"
|
||||
"uniform float4 cColMatrix[5] : register(c%d);\n"
|
||||
@ -279,7 +234,7 @@ void PixelShaderCache::Init()
|
||||
"texcol = float4((EncodedDepth.rgb * (16777216.0f/16777215.0f)),1.0f);\n"
|
||||
"ocol0 = float4(dot(texcol,cColMatrix[0]),dot(texcol,cColMatrix[1]),dot(texcol,cColMatrix[2]),dot(texcol,cColMatrix[3])) + cColMatrix[4];\n"
|
||||
"}\n",C_COLORMATRIX);
|
||||
s_DepthMatrixProgram[2] = D3D::CompileAndCreatePixelShader(pprog, (int)strlen(pprog));
|
||||
s_DepthMatrixProgram[1] = D3D::CompileAndCreatePixelShader(pprog, (int)strlen(pprog));
|
||||
|
||||
//9 sample
|
||||
sprintf(pprog, "uniform sampler samp0 : register(s0);\n"
|
||||
@ -297,7 +252,7 @@ void PixelShaderCache::Init()
|
||||
"texcol = float4((EncodedDepth.rgb * (16777216.0f/16777215.0f)),1.0f);\n"
|
||||
"ocol0 = float4(dot(texcol,cColMatrix[0]),dot(texcol,cColMatrix[1]),dot(texcol,cColMatrix[2]),dot(texcol,cColMatrix[3])) + cColMatrix[4];\n"
|
||||
"}\n",C_COLORMATRIX);
|
||||
s_DepthMatrixProgram[3] = D3D::CompileAndCreatePixelShader(pprog, (int)strlen(pprog));
|
||||
s_DepthMatrixProgram[2] = D3D::CompileAndCreatePixelShader(pprog, (int)strlen(pprog));
|
||||
|
||||
Clear();
|
||||
|
||||
@ -325,7 +280,7 @@ void PixelShaderCache::Clear()
|
||||
|
||||
void PixelShaderCache::Shutdown()
|
||||
{
|
||||
for(int i = 0;i<4;i++)
|
||||
for(int i = 0;i<3;i++)
|
||||
{
|
||||
if (s_ColorMatrixProgram[i]) s_ColorMatrixProgram[i]->Release();
|
||||
s_ColorMatrixProgram[i] = NULL;
|
||||
|
@ -116,85 +116,67 @@ static const D3DBLEND d3dDestFactors[8] =
|
||||
D3DBLEND_INVDESTALPHA
|
||||
};
|
||||
|
||||
// 0 0x00
|
||||
// 1 Source & destination
|
||||
// 2 Source & ~destination
|
||||
// 3 Source
|
||||
// 4 ~Source & destination
|
||||
// 5 Destination
|
||||
// 6 Source ^ destination = Source & ~destination | ~Source & destination
|
||||
// 7 Source | destination
|
||||
|
||||
// 8 ~(Source | destination)
|
||||
// 9 ~(Source ^ destination) = ~Source & ~destination | Source & destination
|
||||
// 10 ~Destination
|
||||
// 11 Source | ~destination
|
||||
// 12 ~Source
|
||||
// 13 ~Source | destination
|
||||
// 14 ~(Source & destination)
|
||||
// 15 0xff
|
||||
|
||||
static const D3DBLENDOP d3dLogincOPop[16] =
|
||||
{
|
||||
D3DBLENDOP_ADD,//0
|
||||
D3DBLENDOP_ADD,//1
|
||||
D3DBLENDOP_SUBTRACT,//2
|
||||
D3DBLENDOP_ADD,//3
|
||||
D3DBLENDOP_REVSUBTRACT,//4
|
||||
D3DBLENDOP_ADD,//5
|
||||
D3DBLENDOP_MAX,//6
|
||||
D3DBLENDOP_ADD,//7
|
||||
D3DBLENDOP_ADD,
|
||||
D3DBLENDOP_ADD,
|
||||
D3DBLENDOP_SUBTRACT,
|
||||
D3DBLENDOP_ADD,
|
||||
D3DBLENDOP_REVSUBTRACT,
|
||||
D3DBLENDOP_ADD,
|
||||
D3DBLENDOP_MAX,
|
||||
D3DBLENDOP_ADD,
|
||||
|
||||
D3DBLENDOP_MAX,//8
|
||||
D3DBLENDOP_MAX,//9
|
||||
D3DBLENDOP_ADD,//10
|
||||
D3DBLENDOP_ADD,//11
|
||||
D3DBLENDOP_ADD,//12
|
||||
D3DBLENDOP_ADD,//13
|
||||
D3DBLENDOP_ADD,//14
|
||||
D3DBLENDOP_ADD//15
|
||||
D3DBLENDOP_MAX,
|
||||
D3DBLENDOP_MAX,
|
||||
D3DBLENDOP_ADD,
|
||||
D3DBLENDOP_ADD,
|
||||
D3DBLENDOP_ADD,
|
||||
D3DBLENDOP_ADD,
|
||||
D3DBLENDOP_ADD,
|
||||
D3DBLENDOP_ADD
|
||||
};
|
||||
|
||||
static const D3DBLEND d3dLogicOpSrcFactors[16] =
|
||||
{
|
||||
D3DBLEND_ZERO,//0
|
||||
D3DBLEND_DESTCOLOR,//1
|
||||
D3DBLEND_ONE,//2
|
||||
D3DBLEND_ONE,//3
|
||||
D3DBLEND_DESTCOLOR,//4
|
||||
D3DBLEND_ZERO,//5
|
||||
D3DBLEND_INVDESTCOLOR,//6
|
||||
D3DBLEND_INVDESTCOLOR,//7
|
||||
D3DBLEND_ZERO,
|
||||
D3DBLEND_DESTCOLOR,
|
||||
D3DBLEND_ONE,
|
||||
D3DBLEND_ONE,
|
||||
D3DBLEND_DESTCOLOR,
|
||||
D3DBLEND_ZERO,
|
||||
D3DBLEND_INVDESTCOLOR,
|
||||
D3DBLEND_INVDESTCOLOR,
|
||||
|
||||
D3DBLEND_INVSRCCOLOR,//8
|
||||
D3DBLEND_INVSRCCOLOR,//9
|
||||
D3DBLEND_INVDESTCOLOR,//10
|
||||
D3DBLEND_ONE,//11
|
||||
D3DBLEND_INVSRCCOLOR,//12
|
||||
D3DBLEND_INVSRCCOLOR,//13
|
||||
D3DBLEND_INVDESTCOLOR,//14
|
||||
D3DBLEND_ONE//15
|
||||
D3DBLEND_INVSRCCOLOR,
|
||||
D3DBLEND_INVSRCCOLOR,
|
||||
D3DBLEND_INVDESTCOLOR,
|
||||
D3DBLEND_ONE,
|
||||
D3DBLEND_INVSRCCOLOR,
|
||||
D3DBLEND_INVSRCCOLOR,
|
||||
D3DBLEND_INVDESTCOLOR,
|
||||
D3DBLEND_ONE
|
||||
};
|
||||
|
||||
static const D3DBLEND d3dLogicOpDestFactors[16] =
|
||||
{
|
||||
D3DBLEND_ZERO,//0
|
||||
D3DBLEND_ZERO,//1
|
||||
D3DBLEND_INVSRCCOLOR,//2
|
||||
D3DBLEND_ZERO,//3
|
||||
D3DBLEND_ONE,//4
|
||||
D3DBLEND_ONE,//5
|
||||
D3DBLEND_INVSRCCOLOR,//6
|
||||
D3DBLEND_ONE,//7
|
||||
D3DBLEND_ZERO,
|
||||
D3DBLEND_ZERO,
|
||||
D3DBLEND_INVSRCCOLOR,
|
||||
D3DBLEND_ZERO,
|
||||
D3DBLEND_ONE,
|
||||
D3DBLEND_ONE,
|
||||
D3DBLEND_INVSRCCOLOR,
|
||||
D3DBLEND_ONE,
|
||||
|
||||
D3DBLEND_INVDESTCOLOR,//8
|
||||
D3DBLEND_SRCCOLOR,//9
|
||||
D3DBLEND_INVDESTCOLOR,//10
|
||||
D3DBLEND_INVDESTCOLOR,//11
|
||||
D3DBLEND_INVSRCCOLOR,//12
|
||||
D3DBLEND_ONE,//13
|
||||
D3DBLEND_INVSRCCOLOR,//14
|
||||
D3DBLEND_ONE//15
|
||||
D3DBLEND_INVDESTCOLOR,
|
||||
D3DBLEND_SRCCOLOR,
|
||||
D3DBLEND_INVDESTCOLOR,
|
||||
D3DBLEND_INVDESTCOLOR,
|
||||
D3DBLEND_INVSRCCOLOR,
|
||||
D3DBLEND_ONE,
|
||||
D3DBLEND_INVSRCCOLOR,
|
||||
D3DBLEND_ONE
|
||||
};
|
||||
|
||||
static const D3DCULL d3dCullModes[4] =
|
||||
@ -269,8 +251,8 @@ bool Renderer::Init()
|
||||
UpdateActiveConfig();
|
||||
int fullScreenRes, x, y, w_temp, h_temp;
|
||||
s_blendMode = 0;
|
||||
// Multisample Anti-aliasing hasn't been implemented yet
|
||||
int backbuffer_ms_mode = 0; // g_ActiveConfig.iMultisampleMode;
|
||||
// Multisample Anti-aliasing hasn't been implemented yet use supersamling instead
|
||||
int backbuffer_ms_mode = 0;
|
||||
|
||||
g_VideoInitialize.pRequestWindowSize(x, y, w_temp, h_temp);
|
||||
|
||||
@ -308,26 +290,9 @@ bool Renderer::Init()
|
||||
|
||||
s_LastAA = (g_ActiveConfig.iMultisampleMode > 3)?0:g_ActiveConfig.iMultisampleMode;
|
||||
|
||||
float SupersampleCoeficient = 1.0f;
|
||||
switch (s_LastAA)
|
||||
{
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
SupersampleCoeficient = 2.0f;
|
||||
break;
|
||||
case 3:
|
||||
SupersampleCoeficient = 3.0f;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
|
||||
xScale *= SupersampleCoeficient;
|
||||
yScale *= SupersampleCoeficient;
|
||||
|
||||
EFBxScale = ceilf(xScale);
|
||||
EFByScale = ceilf(yScale);
|
||||
float SupersampleCoeficient = (s_LastAA % 3) + 1;
|
||||
EFBxScale = (s_LastAA / 3) + 1 * SupersampleCoeficient;
|
||||
EFByScale = EFBxScale;
|
||||
|
||||
s_target_width = EFB_WIDTH * EFBxScale;
|
||||
s_target_height = EFB_HEIGHT * EFByScale;
|
||||
@ -423,16 +388,6 @@ void Renderer::DrawDebugText()
|
||||
std::string T1 = "", T2 = "";
|
||||
std::vector<std::string> T0;
|
||||
|
||||
/*
|
||||
int W, H;
|
||||
sscanf(g_ActiveConfig.cInternalRes, "%dx%d", &W, &H);
|
||||
std::string OSDM1 =
|
||||
g_ActiveConfig.bNativeResolution || g_ActiveConfig.b2xResolution ?
|
||||
(g_ActiveConfig.bNativeResolution ?
|
||||
StringFromFormat("%i x %i (native)", OSDInternalW, OSDInternalH)
|
||||
: StringFromFormat("%i x %i (2x)", OSDInternalW, OSDInternalH))
|
||||
: StringFromFormat("%i x %i (custom)", W, H);
|
||||
*/
|
||||
std::string OSDM1 = StringFromFormat("%i x %i", OSDInternalW, OSDInternalH);
|
||||
std::string OSDM21;
|
||||
switch(g_ActiveConfig.iAspectRatio)
|
||||
@ -494,16 +449,6 @@ void Renderer::RenderText(const char *text, int left, int top, u32 color)
|
||||
D3D::font.DrawTextScaled((float)left, (float)top, 20, 20, 0.0f, color, text, false);
|
||||
}
|
||||
|
||||
void dumpMatrix(D3DXMATRIX &mtx)
|
||||
{
|
||||
for (int y = 0; y < 4; y++)
|
||||
{
|
||||
char temp[256];
|
||||
sprintf(temp,"%4.4f %4.4f %4.4f %4.4f", mtx.m[y][0], mtx.m[y][1], mtx.m[y][2], mtx.m[y][3]);
|
||||
g_VideoInitialize.pLog(temp, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
TargetRectangle Renderer::ConvertEFBRectangle(const EFBRectangle& rc)
|
||||
{
|
||||
int Xstride = (s_Fulltarget_width - s_target_width) / 2;
|
||||
@ -597,27 +542,14 @@ bool Renderer::SetScissorRect()
|
||||
rc.right = (int)((float)bpmem.scissorBR.x - xoff - 341);
|
||||
rc.bottom = (int)((float)bpmem.scissorBR.y - yoff - 341);
|
||||
|
||||
int Xstride = (s_Fulltarget_width - s_target_width) / 2;
|
||||
int Ystride = (s_Fulltarget_height - s_target_height) / 2;
|
||||
|
||||
rc.left = (int)(rc.left * EFBxScale);
|
||||
rc.top = (int)(rc.top * EFByScale);
|
||||
rc.right = (int)(rc.right * EFBxScale);
|
||||
rc.bottom = (int)(rc.bottom * EFByScale);
|
||||
|
||||
if (rc.left < 0) rc.left = 0;
|
||||
if (rc.right < 0) rc.right = 0;
|
||||
if (rc.left > s_target_width) rc.left = s_target_width;
|
||||
if (rc.right > s_target_width) rc.right = s_target_width;
|
||||
if (rc.left > EFB_WIDTH) rc.left = EFB_WIDTH;
|
||||
if (rc.right > EFB_WIDTH) rc.right = EFB_WIDTH;
|
||||
if (rc.top < 0) rc.top = 0;
|
||||
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;
|
||||
|
||||
rc.left += Xstride;
|
||||
rc.top += Ystride;
|
||||
rc.right += Xstride;
|
||||
rc.bottom += Ystride;
|
||||
if (rc.top > EFB_HEIGHT) rc.top = EFB_HEIGHT;
|
||||
if (rc.bottom > EFB_HEIGHT) rc.bottom = EFB_HEIGHT;
|
||||
|
||||
if (rc.left > rc.right)
|
||||
{
|
||||
@ -631,8 +563,16 @@ bool Renderer::SetScissorRect()
|
||||
rc.bottom = rc.top;
|
||||
rc.top = temp;
|
||||
}
|
||||
|
||||
if (rc.right >= rc.left && rc.bottom >= rc.top)
|
||||
|
||||
int Xstride = (s_Fulltarget_width - s_target_width) / 2;
|
||||
int Ystride = (s_Fulltarget_height - s_target_height) / 2;
|
||||
|
||||
rc.left = (int)(rc.left * EFBxScale) + Xstride;
|
||||
rc.top = (int)(rc.top * EFByScale) + Ystride;
|
||||
rc.right = (int)(rc.right * EFBxScale) + Xstride;
|
||||
rc.bottom = (int)(rc.bottom * EFByScale) + Ystride;
|
||||
|
||||
if (rc.right != rc.left && rc.bottom != rc.top)
|
||||
{
|
||||
D3D::dev->SetScissorRect(&rc);
|
||||
return true;
|
||||
@ -761,7 +701,7 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
|
||||
Renderer::GetFullTargetHeight(),
|
||||
4,4,
|
||||
(BufferFormat == FOURCC_RAWZ)?PixelShaderCache::GetColorMatrixProgram(0):PixelShaderCache::GetDepthMatrixProgram(0),
|
||||
VertexShaderCache::GetSimpleVertexShader());
|
||||
VertexShaderCache::GetSimpleVertexShader(0));
|
||||
|
||||
D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER);
|
||||
|
||||
@ -959,8 +899,7 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaE
|
||||
D3D::ChangeRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS);
|
||||
D3D::drawClearQuad(color ,(z & 0xFFFFFF) / float(0xFFFFFF),PixelShaderCache::GetClearProgram(),VertexShaderCache::GetClearVertexShader());
|
||||
if (zEnable)
|
||||
D3D::RefreshRenderState(D3DRS_ZFUNC);
|
||||
//D3D::dev->Clear(0, NULL, (colorEnable ? D3DCLEAR_TARGET : 0)| ( zEnable ? D3DCLEAR_ZBUFFER : 0), color | ((alphaEnable)?0:0xFF000000),(z & 0xFFFFFF) / float(0xFFFFFF), 0);
|
||||
D3D::RefreshRenderState(D3DRS_ZFUNC);
|
||||
UpdateViewport();
|
||||
SetScissorRect();
|
||||
}
|
||||
@ -1118,7 +1057,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
||||
drawRc.right = 1;
|
||||
}
|
||||
|
||||
D3D::drawShadedTexSubQuad(xfbSource->texture,&sourceRc,xfbSource->texWidth,xfbSource->texHeight,&drawRc,Width,Height,PixelShaderCache::GetColorCopyProgram(0),VertexShaderCache::GetSimpleVertexShader());
|
||||
D3D::drawShadedTexSubQuad(xfbSource->texture,&sourceRc,xfbSource->texWidth,xfbSource->texHeight,&drawRc,Width,Height,PixelShaderCache::GetColorCopyProgram(0),VertexShaderCache::GetSimpleVertexShader(0));
|
||||
}
|
||||
|
||||
D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER);
|
||||
@ -1133,7 +1072,6 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
||||
if(s_bScreenshot)
|
||||
{
|
||||
s_criticalScreenshot.Enter();
|
||||
|
||||
// create a R8G8B8 surface for the screenshot (no alpha channel)
|
||||
// otherwise funky screenshots get saved
|
||||
LPDIRECT3DSURFACE9 screenshot_surface;
|
||||
@ -1145,7 +1083,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
||||
}
|
||||
else
|
||||
PanicAlert("Failed to create surface for screenshot!");
|
||||
|
||||
|
||||
s_bScreenshot = false;
|
||||
s_criticalScreenshot.Leave();
|
||||
}
|
||||
@ -1256,29 +1194,11 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
|
||||
yScale = (float)(dst_rect.bottom - dst_rect.top) / (float)s_XFB_height;
|
||||
}
|
||||
|
||||
float SupersampleCoeficient = 1.0f;
|
||||
switch (s_LastAA)
|
||||
{
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
SupersampleCoeficient = 2.0f;
|
||||
break;
|
||||
case 3:
|
||||
SupersampleCoeficient = 3.0f;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
|
||||
xScale *= SupersampleCoeficient;
|
||||
yScale *= SupersampleCoeficient;
|
||||
|
||||
EFBxScale = ceilf(xScale);
|
||||
EFByScale = ceilf(yScale);
|
||||
|
||||
s_target_width = EFB_WIDTH * ceilf(EFBxScale);
|
||||
s_target_height = EFB_HEIGHT * ceilf(EFByScale);
|
||||
float SupersampleCoeficient = (s_LastAA % 3) + 1;
|
||||
EFBxScale = (s_LastAA / 3) + 1 * SupersampleCoeficient;
|
||||
EFByScale = EFBxScale;
|
||||
s_target_width = EFB_WIDTH * EFBxScale;
|
||||
s_target_height = EFB_HEIGHT * EFByScale;
|
||||
D3D::dev->SetRenderTarget(0, D3D::GetBackBufferSurface());
|
||||
D3D::dev->SetDepthStencilSurface(D3D::GetBackBufferDepthSurface());
|
||||
if(WindowResized)
|
||||
@ -1413,7 +1333,7 @@ void Renderer::SetSamplerState(int stage, int texindex)
|
||||
min = (tm0.min_filter & 4) ? D3DTEXF_LINEAR : D3DTEXF_POINT;
|
||||
mag = tm0.mag_filter ? D3DTEXF_LINEAR : D3DTEXF_POINT;
|
||||
mip = (tm0.min_filter == 8)?D3DTEXF_NONE:d3dMipFilters[tm0.min_filter & 3];
|
||||
if((tm0.min_filter & 3) && (tm0.min_filter != 8) && ((tm1.max_lod >> 4) == 0)) mip = D3DTEXF_NONE;
|
||||
if((tm0.min_filter & 3) && (tm0.min_filter != 8) && ((tm1.max_lod >> 5) == 0)) mip = D3DTEXF_NONE;
|
||||
}
|
||||
if (texindex)
|
||||
stage += 4;
|
||||
@ -1429,7 +1349,6 @@ void Renderer::SetSamplerState(int stage, int texindex)
|
||||
|
||||
D3D::SetSamplerState(stage, D3DSAMP_ADDRESSU, d3dClamps[tm0.wrap_s]);
|
||||
D3D::SetSamplerState(stage, D3DSAMP_ADDRESSV, d3dClamps[tm0.wrap_t]);
|
||||
//just a test but it seems to work
|
||||
float lodbias = tm0.lod_bias / 32.0f;
|
||||
D3D::SetSamplerState(stage,D3DSAMP_MIPMAPLODBIAS,*(DWORD*)&lodbias);
|
||||
D3D::SetSamplerState(stage,D3DSAMP_MAXMIPLEVEL,tm1.min_lod>>5);
|
||||
|
@ -188,7 +188,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
|
||||
if (!g_ActiveConfig.bSafeTextureCache)
|
||||
hash_value = ((u32 *)ptr)[0];
|
||||
|
||||
if (entry.isRenderTarget || ((address == entry.addr) && (hash_value == entry.hash) && FullFormat == entry.fmt))
|
||||
if (entry.isRenderTarget || ((address == entry.addr) && (hash_value == entry.hash) && FullFormat == entry.fmt && entry.MipLevels <= maxlevel))
|
||||
{
|
||||
entry.frameCount = frameCount;
|
||||
D3D::SetTexture(stage, entry.texture);
|
||||
@ -200,7 +200,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
|
||||
// instead of destroying it and having to create a new one.
|
||||
// Might speed up movie playback very, very slightly.
|
||||
|
||||
if (width == entry.w && height==entry.h && FullFormat == entry.fmt)
|
||||
if (width == entry.w && height==entry.h && FullFormat == entry.fmt && entry.MipLevels == maxlevel)
|
||||
{
|
||||
skip_texture_create = true;
|
||||
}
|
||||
@ -286,6 +286,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
|
||||
TexLevels = (isPow2 && UseNativeMips && (maxlevel > 0)) ? (int)(log((double)TexLevels)/log((double)2)) + 1 : ((isPow2)? 0 : 1);
|
||||
if(TexLevels > maxlevel && maxlevel > 0)
|
||||
TexLevels = maxlevel;
|
||||
entry.MipLevels = maxlevel;
|
||||
if (!skip_texture_create)
|
||||
{
|
||||
entry.texture = D3D::CreateTexture2D((BYTE*)temp, width, height, expandedWidth, d3d_fmt, swap_r_b, TexLevels);
|
||||
@ -361,25 +362,11 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo
|
||||
int tex_w = (abs(source_rect.GetWidth()) >> bScaleByHalf);
|
||||
int tex_h = (abs(source_rect.GetHeight()) >> bScaleByHalf);
|
||||
//compensate the texture grow if supersampling is enabled to conserve memory usage
|
||||
float SuperSampleCompensation = 1.0f;
|
||||
float SuperSampleCompensation = (g_ActiveConfig.iMultisampleMode % 3) + 1;
|
||||
SuperSampleCompensation = 1.0f / SuperSampleCompensation;
|
||||
float xScale = Renderer::GetTargetScaleX();
|
||||
float yScale = Renderer::GetTargetScaleY();
|
||||
if(g_ActiveConfig.iMultisampleMode > 0 && g_ActiveConfig.iMultisampleMode < 4)
|
||||
{
|
||||
switch (g_ActiveConfig.iMultisampleMode)
|
||||
{
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
SuperSampleCompensation = 0.5f;
|
||||
break;
|
||||
case 3:
|
||||
SuperSampleCompensation = 1.0f/3.0f;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
int Scaledtex_w = (g_ActiveConfig.bCopyEFBScaled)?((int)(xScale * SuperSampleCompensation * tex_w)):tex_w;
|
||||
int Scaledtex_h = (g_ActiveConfig.bCopyEFBScaled)?((int)(yScale * SuperSampleCompensation * tex_h)):tex_h;
|
||||
|
||||
@ -585,7 +572,7 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo
|
||||
Scaledtex_w,
|
||||
Scaledtex_h,
|
||||
((bformat != FOURCC_RAWZ && bformat != D3DFMT_D24X8) && bFromZBuffer)? PixelShaderCache::GetDepthMatrixProgram(SSAAMode): PixelShaderCache::GetColorMatrixProgram(SSAAMode),
|
||||
(SSAAMode != 0)? VertexShaderCache::GetFSAAVertexShader() : VertexShaderCache::GetSimpleVertexShader());
|
||||
VertexShaderCache::GetSimpleVertexShader(SSAAMode));
|
||||
|
||||
|
||||
D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER);
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
u32 oldpixel;
|
||||
|
||||
int frameCount;
|
||||
int w, h, fmt;
|
||||
int w, h, fmt,MipLevels;
|
||||
int Scaledw, Scaledh;
|
||||
|
||||
float scaleX, scaleY; // Hires texutres need this
|
||||
|
@ -271,7 +271,7 @@ void EncodeToRamUsingShader(LPDIRECT3DPIXELSHADER9 shader, LPDIRECT3DTEXTURE9 sr
|
||||
|
||||
|
||||
// Draw...
|
||||
D3D::drawShadedTexQuad(srcTexture,&SrcRect,1,1,dstWidth,dstHeight,shader,VertexShaderCache::GetSimpleVertexShader());
|
||||
D3D::drawShadedTexQuad(srcTexture,&SrcRect,1,1,dstWidth,dstHeight,shader,VertexShaderCache::GetSimpleVertexShader(0));
|
||||
hr = D3D::dev->SetRenderTarget(0, FBManager.GetEFBColorRTSurface());
|
||||
hr = D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface());
|
||||
Renderer::RestoreAPIState();
|
||||
@ -414,8 +414,7 @@ void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, LPDIRECT3DTEXTURE
|
||||
return;
|
||||
}
|
||||
|
||||
float srcFormatFactor = 0.5f;
|
||||
float srcFmtWidth = srcWidth * srcFormatFactor;
|
||||
int srcFmtWidth = srcWidth / 2;
|
||||
|
||||
Renderer::ResetAPIState(); // reset any game specific settings
|
||||
LPDIRECT3DTEXTURE9 s_srcTexture = D3D::CreateTexture2D(srcAddr, srcFmtWidth, srcHeight, srcFmtWidth, D3DFMT_A8R8G8B8, false);
|
||||
@ -466,7 +465,7 @@ void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, LPDIRECT3DTEXTURE
|
||||
srcWidth,
|
||||
srcHeight,
|
||||
s_yuyvToRgbProgram,
|
||||
VertexShaderCache::GetSimpleVertexShader());
|
||||
VertexShaderCache::GetSimpleVertexShader(0));
|
||||
|
||||
|
||||
D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER);
|
||||
|
@ -269,7 +269,7 @@ void Flush()
|
||||
tex.texImage0[i&3].format, tex.texTlut[i&3].tmem_offset<<9,
|
||||
tex.texTlut[i&3].tlut_format,
|
||||
(tex.texMode0[i&3].min_filter & 3) && (tex.texMode0[i&3].min_filter != 8) && g_ActiveConfig.bUseNativeMips,
|
||||
(tex.texMode1[i&3].max_lod >> 4));
|
||||
(tex.texMode1[i&3].max_lod >> 5));
|
||||
|
||||
if (tentry) {
|
||||
PixelShaderManager::SetTexDims(i, tentry->w, tentry->h, 0, 0);
|
||||
|
@ -40,15 +40,14 @@ const VertexShaderCache::VSCacheEntry *VertexShaderCache::last_entry;
|
||||
|
||||
static float GC_ALIGNED16(lastVSconstants[C_FOGPARAMS + 8][4]);
|
||||
|
||||
static LPDIRECT3DVERTEXSHADER9 SimpleVertexShader;
|
||||
static LPDIRECT3DVERTEXSHADER9 SimpleVertexShader[3];
|
||||
static LPDIRECT3DVERTEXSHADER9 ClearVertexShader;
|
||||
static LPDIRECT3DVERTEXSHADER9 FSAAVertexShader;
|
||||
|
||||
LinearDiskCache g_vs_disk_cache;
|
||||
|
||||
LPDIRECT3DVERTEXSHADER9 VertexShaderCache::GetSimpleVertexShader()
|
||||
LPDIRECT3DVERTEXSHADER9 VertexShaderCache::GetSimpleVertexShader(int level)
|
||||
{
|
||||
return SimpleVertexShader;
|
||||
return SimpleVertexShader[level % 3];
|
||||
}
|
||||
|
||||
LPDIRECT3DVERTEXSHADER9 VertexShaderCache::GetClearVertexShader()
|
||||
@ -56,10 +55,6 @@ LPDIRECT3DVERTEXSHADER9 VertexShaderCache::GetClearVertexShader()
|
||||
return ClearVertexShader;
|
||||
}
|
||||
|
||||
LPDIRECT3DVERTEXSHADER9 VertexShaderCache::GetFSAAVertexShader()
|
||||
{
|
||||
return FSAAVertexShader;
|
||||
}
|
||||
|
||||
void SetVSConstant4f(int const_number, float f1, float f2, float f3, float f4)
|
||||
{
|
||||
@ -148,7 +143,7 @@ void VertexShaderCache::Init()
|
||||
"return OUT;\n"
|
||||
"}\n");
|
||||
|
||||
SimpleVertexShader = D3D::CompileAndCreateVertexShader(vProg, (int)strlen(vProg));
|
||||
SimpleVertexShader[0] = D3D::CompileAndCreateVertexShader(vProg, (int)strlen(vProg));
|
||||
|
||||
sprintf(vProg,"struct VSOUTPUT\n"
|
||||
"{\n"
|
||||
@ -180,14 +175,38 @@ void VertexShaderCache::Init()
|
||||
"VSOUTPUT OUT;"
|
||||
"OUT.vPosition = inPosition;\n"
|
||||
"OUT.vTexCoord = inTEX0.xyyx;\n"
|
||||
"OUT.vTexCoord1 = inTEX0.xyyx + (float4(-0.1830127f,-0.6830127f,-0.7071068f,-1.2247449f) * inTEX1.xyyx);\n"
|
||||
"OUT.vTexCoord2 = inTEX0.xyyx + (float4(-0.6830127f, 0.1830127f, 0.7071068f, 1.2247449f) * inTEX1.xyyx);\n"
|
||||
"OUT.vTexCoord3 = inTEX0.xyyx + (float4( 0.6830127f,-0.1830127f,-1.2247449f, 0.7071068f) * inTEX1.xyyx);\n"
|
||||
"OUT.vTexCoord4 = inTEX0.xyyx + (float4( 0.1830127f, 0.6830127f, 1.2247449f,-0.7071068f) * inTEX1.xyyx);\n"
|
||||
"OUT.vTexCoord1 = inTEX0.xyyx + (float4(-0.5f,-0.5f,-0.5f,-0.5f) * inTEX1.xyyx);\n"
|
||||
"OUT.vTexCoord2 = inTEX0.xyyx + (float4(-0.5f, 0.5f, 0.5f,-0.5f) * inTEX1.xyyx);\n"
|
||||
"OUT.vTexCoord3 = inTEX0.xyyx + (float4( 0.5f,-0.5f,-0.5f, 0.5f) * inTEX1.xyyx);\n"
|
||||
"OUT.vTexCoord4 = inTEX0.xyyx + (float4( 0.5f, 0.5f, 0.5f, 0.5f) * inTEX1.xyyx);\n"
|
||||
"OUT.vTexCoord5 = inTEX2;\n"
|
||||
"return OUT;\n"
|
||||
"}\n");
|
||||
FSAAVertexShader = D3D::CompileAndCreateVertexShader(vProg, (int)strlen(vProg));
|
||||
SimpleVertexShader[1] = D3D::CompileAndCreateVertexShader(vProg, (int)strlen(vProg));
|
||||
|
||||
sprintf(vProg, "struct VSOUTPUT\n"
|
||||
"{\n"
|
||||
"float4 vPosition : POSITION;\n"
|
||||
"float4 vTexCoord : TEXCOORD0;\n"
|
||||
"float4 vTexCoord1 : TEXCOORD1;\n"
|
||||
"float4 vTexCoord2 : TEXCOORD2;\n"
|
||||
"float4 vTexCoord3 : TEXCOORD3;\n"
|
||||
"float4 vTexCoord4 : TEXCOORD4;\n"
|
||||
"float4 vTexCoord5 : TEXCOORD5;\n"
|
||||
"};\n"
|
||||
"VSOUTPUT main(float4 inPosition : POSITION,float2 inTEX0 : TEXCOORD0,float2 inTEX1 : TEXCOORD1,float4 inTEX2 : TEXCOORD2)\n"
|
||||
"{\n"
|
||||
"VSOUTPUT OUT;"
|
||||
"OUT.vPosition = inPosition;\n"
|
||||
"OUT.vTexCoord = inTEX0.xyyx;\n"
|
||||
"OUT.vTexCoord1 = inTEX0.xyyx + (float4(-1.0f,-1.0f,-1.0f, 1.0f) * inTEX1.xyyx);\n"
|
||||
"OUT.vTexCoord2 = inTEX0.xyyx + (float4(-1.0f, 0.0f, 0.0f, 1.0f) * inTEX1.xyyx);\n"
|
||||
"OUT.vTexCoord3 = inTEX0.xyyx + (float4(-1.0f, 1.0f, 1.0f, 1.0f) * inTEX1.xyyx);\n"
|
||||
"OUT.vTexCoord4 = inTEX0.xyyx + (float4( 0.0f, 1.0f,-1.0f, 0.0f) * inTEX1.xyyx);\n"
|
||||
"OUT.vTexCoord5 = inTEX2;\n"
|
||||
"return OUT;\n"
|
||||
"}\n");
|
||||
SimpleVertexShader[2] = D3D::CompileAndCreateVertexShader(vProg, (int)strlen(vProg));
|
||||
|
||||
Clear();
|
||||
delete [] vProg;
|
||||
@ -215,17 +234,17 @@ void VertexShaderCache::Clear()
|
||||
|
||||
void VertexShaderCache::Shutdown()
|
||||
{
|
||||
if (SimpleVertexShader)
|
||||
SimpleVertexShader->Release();
|
||||
SimpleVertexShader = NULL;
|
||||
for (int i = 0; i<3;i++)
|
||||
{
|
||||
if (SimpleVertexShader[i])
|
||||
SimpleVertexShader[i]->Release();
|
||||
SimpleVertexShader[i] = NULL;
|
||||
}
|
||||
|
||||
if (ClearVertexShader)
|
||||
ClearVertexShader->Release();
|
||||
ClearVertexShader = NULL;
|
||||
|
||||
if (FSAAVertexShader)
|
||||
FSAAVertexShader->Release();
|
||||
FSAAVertexShader = NULL;
|
||||
|
||||
|
||||
Clear();
|
||||
g_vs_disk_cache.Sync();
|
||||
|
@ -55,9 +55,8 @@ public:
|
||||
static void Clear();
|
||||
static void Shutdown();
|
||||
static bool SetShader(u32 components);
|
||||
static LPDIRECT3DVERTEXSHADER9 GetSimpleVertexShader();
|
||||
static LPDIRECT3DVERTEXSHADER9 GetClearVertexShader();
|
||||
static LPDIRECT3DVERTEXSHADER9 GetFSAAVertexShader();
|
||||
static LPDIRECT3DVERTEXSHADER9 GetSimpleVertexShader(int level);
|
||||
static LPDIRECT3DVERTEXSHADER9 GetClearVertexShader();
|
||||
static bool InsertByteCode(const VERTEXSHADERUID &uid, const u8 *bytecode, int bytecodelen, bool activate);
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
static std::string GetCurrentShaderCode();
|
||||
|
@ -12,11 +12,13 @@
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (United States) resources
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@ -44,7 +46,7 @@ BEGIN
|
||||
CONTROL "&Widescreen Hack",IDC_WIDESCREEN_HACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,161,25,67,10
|
||||
LTEXT "&Aspect Ratio:",IDC_STATIC,9,40,48,8
|
||||
COMBOBOX IDC_ASPECTRATIO,68,39,89,57,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "&Anti-alias mode:",IDC_STATIC,9,59,51,8
|
||||
LTEXT "&Scale - AA mode:",IDC_STATIC,9,59,59,8
|
||||
COMBOBOX IDC_ANTIALIASMODE,68,59,162,73,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
CONTROL "&Enable CPU->EFB access ",IDC_EFB_ACCESS_ENABLE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,7,80,94,11
|
||||
GROUPBOX "Safe Texture Cache Mode",IDC_STATIC,109,94,125,27
|
||||
@ -103,7 +105,7 @@ END
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO
|
||||
GUIDELINES DESIGNINFO
|
||||
BEGIN
|
||||
IDD_ABOUT, DIALOG
|
||||
BEGIN
|
||||
@ -177,7 +179,7 @@ END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // English (United States) resources
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user