Stefan Dösinger : wined3d: Only perform sRGB write correction on formats that advertise it.
Alexandre Julliard
julliard at winehq.org
Thu Jul 22 12:09:19 CDT 2010
Module: wine
Branch: master
Commit: 6b794cbd64ba4a33cde3f349c0af2a3de88c2427
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6b794cbd64ba4a33cde3f349c0af2a3de88c2427
Author: Stefan Dösinger <stefan at codeweavers.com>
Date: Fri Jul 2 22:21:02 2010 +0200
wined3d: Only perform sRGB write correction on formats that advertise it.
---
dlls/wined3d/context.c | 5 +++++
dlls/wined3d/shader.c | 13 +++++++++----
dlls/wined3d/utils.c | 4 +++-
3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 435c315..b8d35c7 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -2192,6 +2192,11 @@ static void context_setup_target(IWineD3DDeviceImpl *device,
{
Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_ALPHABLENDENABLE), StateTable);
}
+ /* Update sRGB writing when switching between formats that do/do not support sRGB writing */
+ if ((old->Flags & WINED3DFMT_FLAG_SRGB_WRITE) != (new->Flags & WINED3DFMT_FLAG_SRGB_WRITE))
+ {
+ Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_SRGBWRITEENABLE), StateTable);
+ }
}
/* When switching away from an offscreen render target, and we're not
diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c
index f26122a..66a81fb 100644
--- a/dlls/wined3d/shader.c
+++ b/dlls/wined3d/shader.c
@@ -2008,10 +2008,16 @@ void find_ps_compile_args(IWineD3DPixelShaderImpl *shader,
IWineD3DStateBlockImpl *stateblock, struct ps_compile_args *args)
{
IWineD3DBaseTextureImpl *texture;
+ IWineD3DDeviceImpl *device = stateblock->device;
UINT i;
memset(args, 0, sizeof(*args)); /* FIXME: Make sure all bits are set. */
- args->srgb_correction = stateblock->renderState[WINED3DRS_SRGBWRITEENABLE] ? 1 : 0;
+ if (stateblock->renderState[WINED3DRS_SRGBWRITEENABLE])
+ {
+ IWineD3DSurfaceImpl *rt = device->render_targets[0];
+ if(rt->resource.format_desc->Flags & WINED3DFMT_FLAG_SRGB_WRITE) args->srgb_correction = 1;
+ }
+
args->np2_fixup = 0;
for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i)
@@ -2036,7 +2042,7 @@ void find_ps_compile_args(IWineD3DPixelShaderImpl *shader,
}
if (shader->baseShader.reg_maps.shader_version.major >= 3)
{
- if (((IWineD3DDeviceImpl *)shader->baseShader.device)->strided_streams.position_transformed)
+ if (device->strided_streams.position_transformed)
{
args->vp_mode = pretransformed;
}
@@ -2058,8 +2064,7 @@ void find_ps_compile_args(IWineD3DPixelShaderImpl *shader,
switch (stateblock->renderState[WINED3DRS_FOGTABLEMODE])
{
case WINED3DFOG_NONE:
- if (((IWineD3DDeviceImpl *)shader->baseShader.device)->strided_streams.position_transformed
- || use_vs(stateblock))
+ if (device->strided_streams.position_transformed || use_vs(stateblock))
{
args->fog = FOG_LINEAR;
break;
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index b38d6c0..7a36998 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -2698,6 +2698,7 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
DWORD ttff;
DWORD cop, aop, carg0, carg1, carg2, aarg0, aarg1, aarg2;
IWineD3DDeviceImpl *device = stateblock->device;
+ IWineD3DSurfaceImpl *rt = device->render_targets[0];
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
for (i = 0; i < gl_info->limits.texture_stages; ++i)
@@ -2886,7 +2887,8 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
break;
}
}
- if(stateblock->renderState[WINED3DRS_SRGBWRITEENABLE]) {
+ if(stateblock->renderState[WINED3DRS_SRGBWRITEENABLE] &&
+ rt->resource.format_desc->Flags & WINED3DFMT_FLAG_SRGB_WRITE) {
settings->sRGB_write = 1;
} else {
settings->sRGB_write = 0;
More information about the wine-cvs
mailing list