mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
Second Experimental commit:
corrected peek color and peek z to correctly emulate real hardware formats. implements native gamma correction.(i don't own any game that uses this functionality so i will appreciate feedback) i need a lot of feedback in this changes please enjoy git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6664 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -430,20 +430,20 @@ int CD3DFont::DrawTextScaled(float x, float y, float size, float spacing, u32 dw
|
||||
ID3D11SamplerState* linear_copy_sampler = NULL;
|
||||
ID3D11SamplerState* point_copy_sampler = NULL;
|
||||
|
||||
typedef struct { float x,y,z,u,v; } STQVertex;
|
||||
typedef struct { float x,y,z,u,v; } STSQVertex;
|
||||
typedef struct { float x,y,z,u,v,w; } STQVertex;
|
||||
typedef struct { float x,y,z,u,v,w; } STSQVertex;
|
||||
typedef struct { float x,y,z; u32 col; } ClearVertex;
|
||||
typedef struct { float x,y,z; u32 col; } ColVertex;
|
||||
|
||||
struct
|
||||
{
|
||||
float u1, v1, u2, v2;
|
||||
float u1, v1, u2, v2, G;
|
||||
} tex_quad_data;
|
||||
|
||||
struct
|
||||
{
|
||||
MathUtil::Rectangle<float> rdest;
|
||||
float u1, v1, u2, v2;
|
||||
float u1, v1, u2, v2, G;
|
||||
} tex_sub_quad_data;
|
||||
|
||||
struct
|
||||
@ -519,7 +519,8 @@ void drawShadedTexQuad(ID3D11ShaderResourceView* texture,
|
||||
int SourceHeight,
|
||||
ID3D11PixelShader* PShader,
|
||||
ID3D11VertexShader* Vshader,
|
||||
ID3D11InputLayout* layout)
|
||||
ID3D11InputLayout* layout,
|
||||
float Gamma)
|
||||
{
|
||||
float sw = 1.0f /(float) SourceWidth;
|
||||
float sh = 1.0f /(float) SourceHeight;
|
||||
@ -527,18 +528,19 @@ void drawShadedTexQuad(ID3D11ShaderResourceView* texture,
|
||||
float u2 = ((float)rSource->right) * sw;
|
||||
float v1 = ((float)rSource->top) * sh;
|
||||
float v2 = ((float)rSource->bottom) * sh;
|
||||
float G = 1.0f / Gamma;
|
||||
|
||||
STQVertex coords[4] = {
|
||||
{-1.0f, 1.0f, 0.0f, u1, v1},
|
||||
{ 1.0f, 1.0f, 0.0f, u2, v1},
|
||||
{-1.0f,-1.0f, 0.0f, u1, v2},
|
||||
{ 1.0f,-1.0f, 0.0f, u2, v2},
|
||||
{-1.0f, 1.0f, 0.0f, u1, v1, G},
|
||||
{ 1.0f, 1.0f, 0.0f, u2, v1, G},
|
||||
{-1.0f,-1.0f, 0.0f, u1, v2, G},
|
||||
{ 1.0f,-1.0f, 0.0f, u2, v2, G},
|
||||
};
|
||||
|
||||
// only upload the data to VRAM if it changed
|
||||
if (stq_observer ||
|
||||
tex_quad_data.u1 != u1 || tex_quad_data.v1 != v1 ||
|
||||
tex_quad_data.u2 != u2 || tex_quad_data.v2 != v2)
|
||||
tex_quad_data.u2 != u2 || tex_quad_data.v2 != v2 || tex_quad_data.G != G)
|
||||
{
|
||||
stq_offset = util_vbuf->AppendData(coords, sizeof(coords), sizeof(STQVertex));
|
||||
stq_observer = false;
|
||||
@ -547,6 +549,7 @@ void drawShadedTexQuad(ID3D11ShaderResourceView* texture,
|
||||
tex_quad_data.v1 = v1;
|
||||
tex_quad_data.u2 = u2;
|
||||
tex_quad_data.v2 = v2;
|
||||
tex_quad_data.G = G;
|
||||
}
|
||||
UINT stride = sizeof(STQVertex);
|
||||
UINT offset = 0;
|
||||
@ -571,7 +574,8 @@ void drawShadedTexSubQuad(ID3D11ShaderResourceView* texture,
|
||||
const MathUtil::Rectangle<float>* rDest,
|
||||
ID3D11PixelShader* PShader,
|
||||
ID3D11VertexShader* Vshader,
|
||||
ID3D11InputLayout* layout)
|
||||
ID3D11InputLayout* layout,
|
||||
float Gamma)
|
||||
{
|
||||
float sw = 1.0f /(float) SourceWidth;
|
||||
float sh = 1.0f /(float) SourceHeight;
|
||||
@ -579,19 +583,20 @@ void drawShadedTexSubQuad(ID3D11ShaderResourceView* texture,
|
||||
float u2 = (rSource->right ) * sw;
|
||||
float v1 = (rSource->top ) * sh;
|
||||
float v2 = (rSource->bottom) * sh;
|
||||
float G = 1.0f / Gamma;
|
||||
|
||||
STSQVertex coords[4] = {
|
||||
{ rDest->left , rDest->bottom, 0.0f, u1, v1},
|
||||
{ rDest->right, rDest->bottom, 0.0f, u2, v1},
|
||||
{ rDest->left , rDest->top , 0.0f, u1, v2},
|
||||
{ rDest->right, rDest->top , 0.0f, u2, v2},
|
||||
{ rDest->left , rDest->bottom, 0.0f, u1, v1, G},
|
||||
{ rDest->right, rDest->bottom, 0.0f, u2, v1, G},
|
||||
{ rDest->left , rDest->top , 0.0f, u1, v2, G},
|
||||
{ rDest->right, rDest->top , 0.0f, u2, v2, G},
|
||||
};
|
||||
|
||||
// only upload the data to VRAM if it changed
|
||||
if (stsq_observer ||
|
||||
memcmp(rDest, &tex_sub_quad_data.rdest, sizeof(rDest)) != 0 ||
|
||||
tex_sub_quad_data.u1 != u1 || tex_sub_quad_data.v1 != v1 ||
|
||||
tex_sub_quad_data.u2 != u2 || tex_sub_quad_data.v2 != v2)
|
||||
tex_sub_quad_data.u2 != u2 || tex_sub_quad_data.v2 != v2 || tex_sub_quad_data.G != G)
|
||||
{
|
||||
stsq_offset = util_vbuf->AppendData(coords, sizeof(coords), sizeof(STSQVertex));
|
||||
stsq_observer = false;
|
||||
@ -600,6 +605,7 @@ void drawShadedTexSubQuad(ID3D11ShaderResourceView* texture,
|
||||
tex_sub_quad_data.v1 = v1;
|
||||
tex_sub_quad_data.u2 = u2;
|
||||
tex_sub_quad_data.v2 = v2;
|
||||
tex_sub_quad_data.G = G;
|
||||
memcpy(&tex_sub_quad_data.rdest, &rDest, sizeof(rDest));
|
||||
}
|
||||
UINT stride = sizeof(STSQVertex);
|
||||
|
Reference in New Issue
Block a user