Commit e6d52c0c authored by Rico Schüller's avatar Rico Schüller Committed by Alexandre Julliard

wined3d: Add argument check for Type to Get/SetTextureStageState().

parent 7e8ab4c8
......@@ -1575,13 +1575,22 @@ tss_lookup[] =
{FALSE, WINED3DTSS_RESULTARG}, /* 28, D3DTSS_RESULTARG */
};
static HRESULT WINAPI IDirect3DDevice8Impl_GetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue) {
static HRESULT WINAPI IDirect3DDevice8Impl_GetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD *pValue)
{
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
const struct tss_lookup *l = &tss_lookup[Type];
const struct tss_lookup *l;
HRESULT hr;
TRACE("iface %p, stage %u, state %#x, value %p.\n", iface, Stage, Type, pValue);
if (Type >= sizeof(tss_lookup) / sizeof(*tss_lookup))
{
WARN("Invalid Type %#x passed.\n", Type);
return D3D_OK;
}
l = &tss_lookup[Type];
wined3d_mutex_lock();
if (l->sampler_state) hr = IWineD3DDevice_GetSamplerState(This->WineD3DDevice, Stage, l->state, pValue);
else hr = IWineD3DDevice_GetTextureStageState(This->WineD3DDevice, Stage, l->state, pValue);
......@@ -1590,13 +1599,22 @@ static HRESULT WINAPI IDirect3DDevice8Impl_GetTextureStageState(LPDIRECT3DDEVI
return hr;
}
static HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) {
static HRESULT WINAPI IDirect3DDevice8Impl_SetTextureStageState(LPDIRECT3DDEVICE8 iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value)
{
IDirect3DDevice8Impl *This = (IDirect3DDevice8Impl *)iface;
const struct tss_lookup *l = &tss_lookup[Type];
const struct tss_lookup *l;
HRESULT hr;
TRACE("iface %p, stage %u, state %#x, value %#x.\n", iface, Stage, Type, Value);
if (Type >= sizeof(tss_lookup) / sizeof(*tss_lookup))
{
WARN("Invalid Type %#x passed.\n", Type);
return D3D_OK;
}
l = &tss_lookup[Type];
wined3d_mutex_lock();
if (l->sampler_state) hr = IWineD3DDevice_SetSamplerState(This->WineD3DDevice, Stage, l->state, Value);
else hr = IWineD3DDevice_SetTextureStageState(This->WineD3DDevice, Stage, l->state, Value);
......
......@@ -1681,12 +1681,19 @@ static const WINED3DTEXTURESTAGESTATETYPE tss_lookup[] =
WINED3DTSS_CONSTANT, /* 32, D3DTSS_CONSTANT */
};
static HRESULT WINAPI IDirect3DDevice9Impl_GetTextureStageState(LPDIRECT3DDEVICE9EX iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD* pValue) {
static HRESULT WINAPI IDirect3DDevice9Impl_GetTextureStageState(LPDIRECT3DDEVICE9EX iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD *pValue)
{
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hr;
TRACE("iface %p, stage %u, state %#x, value %p.\n", iface, Stage, Type, pValue);
if (Type >= sizeof(tss_lookup) / sizeof(*tss_lookup))
{
WARN("Invalid Type %#x passed.\n", Type);
return D3D_OK;
}
wined3d_mutex_lock();
hr = IWineD3DDevice_GetTextureStageState(This->WineD3DDevice, Stage, tss_lookup[Type], pValue);
wined3d_mutex_unlock();
......@@ -1694,12 +1701,19 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetTextureStageState(LPDIRECT3DDEVI
return hr;
}
static HRESULT WINAPI IDirect3DDevice9Impl_SetTextureStageState(LPDIRECT3DDEVICE9EX iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value) {
static HRESULT WINAPI IDirect3DDevice9Impl_SetTextureStageState(LPDIRECT3DDEVICE9EX iface, DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value)
{
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hr;
TRACE("iface %p, stage %u, state %#x, value %#x.\n", iface, Stage, Type, Value);
if (Type >= sizeof(tss_lookup) / sizeof(*tss_lookup))
{
WARN("Invalid Type %#x passed.\n", Type);
return D3D_OK;
}
wined3d_mutex_lock();
hr = IWineD3DDevice_SetTextureStageState(This->WineD3DDevice, Stage, tss_lookup[Type], Value);
wined3d_mutex_unlock();
......
......@@ -4870,7 +4870,7 @@ IDirect3DDeviceImpl_7_GetTextureStageState(IDirect3DDevice7 *iface,
{
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
HRESULT hr;
const struct tss_lookup *l = &tss_lookup[TexStageStateType];
const struct tss_lookup *l;
TRACE("iface %p, stage %u, state %#x, value %p.\n",
iface, Stage, TexStageStateType, State);
......@@ -4881,10 +4881,11 @@ IDirect3DDeviceImpl_7_GetTextureStageState(IDirect3DDevice7 *iface,
if (TexStageStateType > D3DTSS_TEXTURETRANSFORMFLAGS)
{
WARN("Invalid TexStageStateType %#x passed.\n", TexStageStateType);
*State = 0;
return DD_OK;
}
l = &tss_lookup[TexStageStateType];
EnterCriticalSection(&ddraw_cs);
if (l->sampler_state)
......@@ -5003,7 +5004,7 @@ IDirect3DDeviceImpl_7_SetTextureStageState(IDirect3DDevice7 *iface,
DWORD State)
{
IDirect3DDeviceImpl *This = (IDirect3DDeviceImpl *)iface;
const struct tss_lookup *l = &tss_lookup[TexStageStateType];
const struct tss_lookup *l;
HRESULT hr;
TRACE("iface %p, stage %u, state %#x, value %#x.\n",
......@@ -5015,6 +5016,8 @@ IDirect3DDeviceImpl_7_SetTextureStageState(IDirect3DDevice7 *iface,
return DD_OK;
}
l = &tss_lookup[TexStageStateType];
EnterCriticalSection(&ddraw_cs);
if (l->sampler_state)
......
......@@ -4199,13 +4199,20 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ProcessVertices(IWineD3DDevice *iface,
* Get / Set Texture Stage States
* TODO: Verify against dx9 definitions
*****/
static HRESULT WINAPI IWineD3DDeviceImpl_SetTextureStageState(IWineD3DDevice *iface, DWORD Stage, WINED3DTEXTURESTAGESTATETYPE Type, DWORD Value) {
static HRESULT WINAPI IWineD3DDeviceImpl_SetTextureStageState(IWineD3DDevice *iface, DWORD Stage, WINED3DTEXTURESTAGESTATETYPE Type, DWORD Value)
{
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
DWORD oldValue = This->updateStateBlock->textureState[Stage][Type];
const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
DWORD oldValue;
TRACE("(%p) : Stage=%d, Type=%s(%d), Value=%d\n", This, Stage, debug_d3dtexturestate(Type), Type, Value);
if (Type > WINED3D_HIGHEST_TEXTURE_STATE)
{
WARN("Invalid Type %d passed.\n", Type);
return WINED3D_OK;
}
if (Stage >= gl_info->limits.texture_stages)
{
WARN("Attempting to set stage %u which is higher than the max stage %u, ignoring.\n",
......@@ -4213,6 +4220,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTextureStageState(IWineD3DDevice *if
return WINED3D_OK;
}
oldValue = This->updateStateBlock->textureState[Stage][Type];
This->updateStateBlock->changed.textureState[Stage] |= 1 << Type;
This->updateStateBlock->textureState[Stage][Type] = Value;
......@@ -4276,9 +4284,18 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTextureStageState(IWineD3DDevice *if
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_GetTextureStageState(IWineD3DDevice *iface, DWORD Stage, WINED3DTEXTURESTAGESTATETYPE Type, DWORD* pValue) {
static HRESULT WINAPI IWineD3DDeviceImpl_GetTextureStageState(IWineD3DDevice *iface, DWORD Stage, WINED3DTEXTURESTAGESTATETYPE Type, DWORD *pValue)
{
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
if (Type > WINED3D_HIGHEST_TEXTURE_STATE)
{
WARN("Invalid Type %d passed.\n", Type);
return WINED3D_OK;
}
TRACE("(%p) : requesting Stage %d, Type %d getting %d\n", This, Stage, Type, This->updateStateBlock->textureState[Stage][Type]);
*pValue = This->updateStateBlock->textureState[Stage][Type];
return WINED3D_OK;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment