mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-09-13 09:17:20 -07:00
Added d3dx9-sprite-state patchset
This commit is contained in:
parent
d7bbcc7ad9
commit
42e2a72d37
@ -0,0 +1,127 @@
|
||||
From cf47173eec41f4427248796a781e3aa4463a79db Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Rafa=C5=82=20Mu=C5=BCy=C5=82o?= <galtgendo@o2.pl>
|
||||
Date: Wed, 7 Jun 2023 08:17:59 +1000
|
||||
Subject: [PATCH] d3dx9: Improve handling of Sprite render states
|
||||
|
||||
---
|
||||
dlls/d3dx9_36/sprite.c | 76 +++++++++++++++++++++++-------------------
|
||||
1 file changed, 41 insertions(+), 35 deletions(-)
|
||||
|
||||
diff --git a/dlls/d3dx9_36/sprite.c b/dlls/d3dx9_36/sprite.c
|
||||
index 1a072e52cda..0ce2ab977f3 100644
|
||||
--- a/dlls/d3dx9_36/sprite.c
|
||||
+++ b/dlls/d3dx9_36/sprite.c
|
||||
@@ -193,7 +193,7 @@ static HRESULT WINAPI d3dx9_sprite_SetWorldViewLH(ID3DXSprite *iface,
|
||||
}
|
||||
|
||||
/* Helper function */
|
||||
-static void set_states(struct d3dx9_sprite *object)
|
||||
+static void set_states(struct d3dx9_sprite *object, DWORD flags)
|
||||
{
|
||||
D3DXMATRIX mat;
|
||||
D3DVIEWPORT9 vp;
|
||||
@@ -204,32 +204,35 @@ static void set_states(struct d3dx9_sprite *object)
|
||||
IDirect3DDevice9_SetNPatchMode(object->device, 0.0f);
|
||||
|
||||
/* Render states */
|
||||
- IDirect3DDevice9_SetRenderState(object->device, D3DRS_ALPHABLENDENABLE, TRUE);
|
||||
- IDirect3DDevice9_SetRenderState(object->device, D3DRS_ALPHAFUNC, D3DCMP_GREATER);
|
||||
- IDirect3DDevice9_SetRenderState(object->device, D3DRS_ALPHAREF, 0x00);
|
||||
- IDirect3DDevice9_SetRenderState(object->device, D3DRS_ALPHATESTENABLE, object->alphacmp_caps);
|
||||
- IDirect3DDevice9_SetRenderState(object->device, D3DRS_BLENDOP, D3DBLENDOP_ADD);
|
||||
- IDirect3DDevice9_SetRenderState(object->device, D3DRS_CLIPPING, TRUE);
|
||||
- IDirect3DDevice9_SetRenderState(object->device, D3DRS_CLIPPLANEENABLE, 0);
|
||||
- IDirect3DDevice9_SetRenderState(object->device, D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE |
|
||||
- D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED);
|
||||
- IDirect3DDevice9_SetRenderState(object->device, D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
- IDirect3DDevice9_SetRenderState(object->device, D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
||||
- IDirect3DDevice9_SetRenderState(object->device, D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1);
|
||||
- IDirect3DDevice9_SetRenderState(object->device, D3DRS_ENABLEADAPTIVETESSELLATION, FALSE);
|
||||
- IDirect3DDevice9_SetRenderState(object->device, D3DRS_FILLMODE, D3DFILL_SOLID);
|
||||
- IDirect3DDevice9_SetRenderState(object->device, D3DRS_FOGENABLE, FALSE);
|
||||
- IDirect3DDevice9_SetRenderState(object->device, D3DRS_INDEXEDVERTEXBLENDENABLE, FALSE);
|
||||
- IDirect3DDevice9_SetRenderState(object->device, D3DRS_LIGHTING, FALSE);
|
||||
- IDirect3DDevice9_SetRenderState(object->device, D3DRS_RANGEFOGENABLE, FALSE);
|
||||
- IDirect3DDevice9_SetRenderState(object->device, D3DRS_SEPARATEALPHABLENDENABLE, FALSE);
|
||||
- IDirect3DDevice9_SetRenderState(object->device, D3DRS_SHADEMODE, D3DSHADE_GOURAUD);
|
||||
- IDirect3DDevice9_SetRenderState(object->device, D3DRS_SPECULARENABLE, FALSE);
|
||||
- IDirect3DDevice9_SetRenderState(object->device, D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
- IDirect3DDevice9_SetRenderState(object->device, D3DRS_SRGBWRITEENABLE, FALSE);
|
||||
- IDirect3DDevice9_SetRenderState(object->device, D3DRS_STENCILENABLE, FALSE);
|
||||
- IDirect3DDevice9_SetRenderState(object->device, D3DRS_VERTEXBLEND, FALSE);
|
||||
- IDirect3DDevice9_SetRenderState(object->device, D3DRS_WRAP0, 0);
|
||||
+ if (!(flags & D3DXSPRITE_DONOTMODIFY_RENDERSTATE))
|
||||
+ {
|
||||
+ IDirect3DDevice9_SetRenderState(object->device, D3DRS_ALPHABLENDENABLE, TRUE);
|
||||
+ IDirect3DDevice9_SetRenderState(object->device, D3DRS_ALPHAFUNC, D3DCMP_GREATER);
|
||||
+ IDirect3DDevice9_SetRenderState(object->device, D3DRS_ALPHAREF, 0x00);
|
||||
+ IDirect3DDevice9_SetRenderState(object->device, D3DRS_ALPHATESTENABLE, object->alphacmp_caps);
|
||||
+ IDirect3DDevice9_SetRenderState(object->device, D3DRS_BLENDOP, D3DBLENDOP_ADD);
|
||||
+ IDirect3DDevice9_SetRenderState(object->device, D3DRS_CLIPPING, TRUE);
|
||||
+ IDirect3DDevice9_SetRenderState(object->device, D3DRS_CLIPPLANEENABLE, 0);
|
||||
+ IDirect3DDevice9_SetRenderState(object->device, D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE |
|
||||
+ D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED);
|
||||
+ IDirect3DDevice9_SetRenderState(object->device, D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
+ IDirect3DDevice9_SetRenderState(object->device, D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
||||
+ IDirect3DDevice9_SetRenderState(object->device, D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1);
|
||||
+ IDirect3DDevice9_SetRenderState(object->device, D3DRS_ENABLEADAPTIVETESSELLATION, FALSE);
|
||||
+ IDirect3DDevice9_SetRenderState(object->device, D3DRS_FILLMODE, D3DFILL_SOLID);
|
||||
+ IDirect3DDevice9_SetRenderState(object->device, D3DRS_FOGENABLE, FALSE);
|
||||
+ IDirect3DDevice9_SetRenderState(object->device, D3DRS_INDEXEDVERTEXBLENDENABLE, FALSE);
|
||||
+ IDirect3DDevice9_SetRenderState(object->device, D3DRS_LIGHTING, FALSE);
|
||||
+ IDirect3DDevice9_SetRenderState(object->device, D3DRS_RANGEFOGENABLE, FALSE);
|
||||
+ IDirect3DDevice9_SetRenderState(object->device, D3DRS_SEPARATEALPHABLENDENABLE, FALSE);
|
||||
+ IDirect3DDevice9_SetRenderState(object->device, D3DRS_SHADEMODE, D3DSHADE_GOURAUD);
|
||||
+ IDirect3DDevice9_SetRenderState(object->device, D3DRS_SPECULARENABLE, FALSE);
|
||||
+ IDirect3DDevice9_SetRenderState(object->device, D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
+ IDirect3DDevice9_SetRenderState(object->device, D3DRS_SRGBWRITEENABLE, FALSE);
|
||||
+ IDirect3DDevice9_SetRenderState(object->device, D3DRS_STENCILENABLE, FALSE);
|
||||
+ IDirect3DDevice9_SetRenderState(object->device, D3DRS_VERTEXBLEND, FALSE);
|
||||
+ IDirect3DDevice9_SetRenderState(object->device, D3DRS_WRAP0, 0);
|
||||
+ }
|
||||
|
||||
/* Texture stage states */
|
||||
IDirect3DDevice9_SetTextureStageState(object->device, 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
||||
@@ -266,12 +269,15 @@ static void set_states(struct d3dx9_sprite *object)
|
||||
IDirect3DDevice9_SetSamplerState(object->device, 0, D3DSAMP_SRGBTEXTURE, 0);
|
||||
|
||||
/* Matrices */
|
||||
- D3DXMatrixIdentity(&mat);
|
||||
- IDirect3DDevice9_SetTransform(object->device, D3DTS_WORLD, &mat);
|
||||
- IDirect3DDevice9_SetTransform(object->device, D3DTS_VIEW, &object->view);
|
||||
- IDirect3DDevice9_GetViewport(object->device, &vp);
|
||||
- D3DXMatrixOrthoOffCenterLH(&mat, vp.X+0.5f, (float)vp.Width+vp.X+0.5f, (float)vp.Height+vp.Y+0.5f, vp.Y+0.5f, vp.MinZ, vp.MaxZ);
|
||||
- IDirect3DDevice9_SetTransform(object->device, D3DTS_PROJECTION, &mat);
|
||||
+ if (!(flags & D3DXSPRITE_OBJECTSPACE))
|
||||
+ {
|
||||
+ D3DXMatrixIdentity(&mat);
|
||||
+ IDirect3DDevice9_SetTransform(object->device, D3DTS_WORLD, &mat);
|
||||
+ IDirect3DDevice9_SetTransform(object->device, D3DTS_VIEW, &object->view);
|
||||
+ IDirect3DDevice9_GetViewport(object->device, &vp);
|
||||
+ D3DXMatrixOrthoOffCenterLH(&mat, vp.X+0.5f, (float)vp.Width+vp.X+0.5f, (float)vp.Height+vp.Y+0.5f, vp.Y+0.5f, vp.MinZ, vp.MaxZ);
|
||||
+ IDirect3DDevice9_SetTransform(object->device, D3DTS_PROJECTION, &mat);
|
||||
+ }
|
||||
}
|
||||
|
||||
static HRESULT WINAPI d3dx9_sprite_Begin(ID3DXSprite *iface, DWORD flags)
|
||||
@@ -317,7 +323,7 @@ D3DXSPRITE_SORT_TEXTURE: sort by texture (so that it doesn't change too often)
|
||||
hr=IDirect3DDevice9_BeginStateBlock(This->device);
|
||||
if(hr!=D3D_OK) return hr;
|
||||
|
||||
- set_states(This);
|
||||
+ set_states(This, flags);
|
||||
|
||||
IDirect3DDevice9_SetVertexDeclaration(This->device, This->vdecl);
|
||||
IDirect3DDevice9_SetStreamSource(This->device, 0, NULL, 0, sizeof(struct sprite_vertex));
|
||||
@@ -330,7 +336,7 @@ D3DXSPRITE_SORT_TEXTURE: sort by texture (so that it doesn't change too often)
|
||||
}
|
||||
|
||||
/* Apply device state */
|
||||
- set_states(This);
|
||||
+ set_states(This, flags);
|
||||
|
||||
This->flags=flags;
|
||||
This->ready=TRUE;
|
||||
--
|
||||
2.40.1
|
||||
|
1
patches/d3dx9-sprite-state/definition
Normal file
1
patches/d3dx9-sprite-state/definition
Normal file
@ -0,0 +1 @@
|
||||
Fixes: [54034] d3dx9: Improve sprite rendering state handling.
|
Loading…
Reference in New Issue
Block a user