diff options
author | Axel Davy <[email protected]> | 2015-01-07 18:43:20 +0100 |
---|---|---|
committer | Axel Davy <[email protected]> | 2015-02-06 00:07:18 +0100 |
commit | 42ac71a4e20c04a2cd7cd441274e5c527012a03c (patch) | |
tree | 80ad4134ee3809b9a06639d61f8f96c515968b73 /src/gallium/state_trackers/nine/device9.c | |
parent | 5c61f6344a93e2bddb1984dcc735b8bc587c5db9 (diff) |
st/nine: Implement RESZ hack
This D3D hack allows to resolve a multisampled
depth buffer into a single sampled one.
Note that the implementation is slightly incorrect.
When querying the content of D3DRS_POINTSIZE,
it should return the resz code if it has been set.
This behaviour will be implemented when state changes
will be reworked. For now the current behaviour is ok,
since apps use the D3DCREATE_PUREDEVICE flag when creating
the device, which means they won't read states and in exchange
get better performance.
Reviewed-by: Tiziano Bacocco <[email protected]>
Signed-off-by: Axel Davy <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/nine/device9.c')
-rw-r--r-- | src/gallium/state_trackers/nine/device9.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index b7e83a4bab9..0326442f949 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -1991,6 +1991,60 @@ NineDevice9_GetClipPlane( struct NineDevice9 *This, return D3D_OK; } +#define RESZ_CODE 0x7fa05000 + +static HRESULT +NineDevice9_ResolveZ( struct NineDevice9 *This ) +{ + struct nine_state *state = &This->state; + const struct util_format_description *desc; + struct NineSurface9 *source = state->ds; + struct NineBaseTexture9 *destination = state->texture[0]; + struct pipe_resource *src, *dst; + struct pipe_blit_info blit; + + DBG("RESZ resolve\n"); + + user_assert(source && destination && + destination->base.type == D3DRTYPE_TEXTURE, D3DERR_INVALIDCALL); + + src = source->base.resource; + dst = destination->base.resource; + + user_assert(src && dst, D3DERR_INVALIDCALL); + + /* check dst is depth format. we know already for src */ + desc = util_format_description(dst->format); + user_assert(desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS, D3DERR_INVALIDCALL); + + blit.src.resource = src; + blit.src.level = 0; + blit.src.format = src->format; + blit.src.box.z = 0; + blit.src.box.depth = 1; + blit.src.box.x = 0; + blit.src.box.y = 0; + blit.src.box.width = src->width0; + blit.src.box.height = src->height0; + + blit.dst.resource = dst; + blit.dst.level = 0; + blit.dst.format = dst->format; + blit.dst.box.z = 0; + blit.dst.box.depth = 1; + blit.dst.box.x = 0; + blit.dst.box.y = 0; + blit.dst.box.width = dst->width0; + blit.dst.box.height = dst->height0; + + blit.mask = PIPE_MASK_ZS; + blit.filter = PIPE_TEX_FILTER_NEAREST; + blit.scissor_enable = FALSE; + + This->pipe->blit(This->pipe, &blit); + return D3D_OK; +} + HRESULT WINAPI NineDevice9_SetRenderState( struct NineDevice9 *This, D3DRENDERSTATETYPE State, @@ -2001,6 +2055,9 @@ NineDevice9_SetRenderState( struct NineDevice9 *This, DBG("This=%p State=%u(%s) Value=%08x\n", This, State, nine_d3drs_to_string(State), Value); + if (State == D3DRS_POINTSIZE && Value == RESZ_CODE) + return NineDevice9_ResolveZ(This); + user_assert(State < Elements(state->rs), D3DERR_INVALIDCALL); if (likely(state->rs[State] != Value) || unlikely(This->is_recording)) { |