From c0f21cbaa124fa32509a8d9c14120fc22f0c8c63 Mon Sep 17 00:00:00 2001 From: Axel Davy Date: Wed, 24 Oct 2018 23:28:28 +0200 Subject: [PATCH] st/nine: Add checks for pure device Some Get* functions are forbidden for pure device. Signed-off-by: Axel Davy Part-of: --- src/gallium/frontends/nine/device9.c | 20 +++++++++++++++++++- src/gallium/frontends/nine/device9.h | 2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/gallium/frontends/nine/device9.c b/src/gallium/frontends/nine/device9.c index c5b5eff128e..0d73965f2c4 100644 --- a/src/gallium/frontends/nine/device9.c +++ b/src/gallium/frontends/nine/device9.c @@ -197,6 +197,8 @@ NineDevice9_ctor( struct NineDevice9 *This, if (This->may_swvp) This->caps.MaxVertexShaderConst = NINE_MAX_CONST_F_SWVP; + This->pure = !!(This->params.BehaviorFlags & D3DCREATE_PUREDEVICE); + This->context.pipe = This->screen->context_create(This->screen, NULL, 0); This->pipe_secondary = This->screen->context_create(This->screen, NULL, 0); if (!This->context.pipe || !This->pipe_secondary) { return E_OUTOFMEMORY; } /* guess */ @@ -2042,7 +2044,10 @@ NineDevice9_GetTransform( struct NineDevice9 *This, D3DTRANSFORMSTATETYPE State, D3DMATRIX *pMatrix ) { - D3DMATRIX *M = nine_state_access_transform(&This->state.ff, State, FALSE); + D3DMATRIX *M; + + user_assert(!This->pure, D3DERR_INVALIDCALL); + M = nine_state_access_transform(&This->state.ff, State, FALSE); user_assert(M, D3DERR_INVALIDCALL); *pMatrix = *M; return D3D_OK; @@ -2114,6 +2119,7 @@ HRESULT NINE_WINAPI NineDevice9_GetMaterial( struct NineDevice9 *This, D3DMATERIAL9 *pMaterial ) { + user_assert(!This->pure, D3DERR_INVALIDCALL); user_assert(pMaterial, E_POINTER); *pMaterial = This->state.ff.material; return D3D_OK; @@ -2162,6 +2168,7 @@ NineDevice9_GetLight( struct NineDevice9 *This, { const struct nine_state *state = &This->state; + user_assert(!This->pure, D3DERR_INVALIDCALL); user_assert(pLight, D3DERR_INVALIDCALL); user_assert(Index < state->ff.num_lights, D3DERR_INVALIDCALL); user_assert(state->ff.light[Index].Type < NINED3DLIGHT_INVALID, @@ -2211,6 +2218,7 @@ NineDevice9_GetLightEnable( struct NineDevice9 *This, const struct nine_state *state = &This->state; unsigned i; + user_assert(!This->pure, D3DERR_INVALIDCALL); user_assert(Index < state->ff.num_lights, D3DERR_INVALIDCALL); user_assert(state->ff.light[Index].Type < NINED3DLIGHT_INVALID, D3DERR_INVALIDCALL); @@ -2255,6 +2263,7 @@ NineDevice9_GetClipPlane( struct NineDevice9 *This, { const struct nine_state *state = &This->state; + user_assert(!This->pure, D3DERR_INVALIDCALL); user_assert(Index < PIPE_MAX_CLIP_PLANES, D3DERR_INVALIDCALL); memcpy(pPlane, &state->clip.ucp[Index][0], sizeof(state->clip.ucp[0])); @@ -2294,6 +2303,7 @@ NineDevice9_GetRenderState( struct NineDevice9 *This, D3DRENDERSTATETYPE State, DWORD *pValue ) { + user_assert(!This->pure, D3DERR_INVALIDCALL); user_assert(State < D3DRS_COUNT, D3DERR_INVALIDCALL); *pValue = This->state.rs_advertised[State]; @@ -2529,6 +2539,7 @@ NineDevice9_GetTextureStageState( struct NineDevice9 *This, { const struct nine_state *state = &This->state; + user_assert(!This->pure, D3DERR_INVALIDCALL); user_assert(Stage < ARRAY_SIZE(state->ff.tex_stage), D3DERR_INVALIDCALL); user_assert(Type < ARRAY_SIZE(state->ff.tex_stage[0]), D3DERR_INVALIDCALL); @@ -2568,6 +2579,7 @@ NineDevice9_GetSamplerState( struct NineDevice9 *This, D3DSAMPLERSTATETYPE Type, DWORD *pValue ) { + user_assert(!This->pure, D3DERR_INVALIDCALL); user_assert(Sampler < NINE_MAX_SAMPLERS_PS || Sampler == D3DDMAPSAMPLER || (Sampler >= D3DVERTEXTEXTURESAMPLER0 && @@ -3305,6 +3317,7 @@ NineDevice9_GetVertexShaderConstantF( struct NineDevice9 *This, { const struct nine_state *state = &This->state; + user_assert(!This->pure, D3DERR_INVALIDCALL); user_assert(StartRegister < This->caps.MaxVertexShaderConst, D3DERR_INVALIDCALL); user_assert(StartRegister + Vector4fCount <= This->caps.MaxVertexShaderConst, D3DERR_INVALIDCALL); user_assert(pConstantData, D3DERR_INVALIDCALL); @@ -3373,6 +3386,7 @@ NineDevice9_GetVertexShaderConstantI( struct NineDevice9 *This, const struct nine_state *state = &This->state; int i; + user_assert(!This->pure, D3DERR_INVALIDCALL); user_assert(StartRegister < (This->may_swvp ? NINE_MAX_CONST_I_SWVP : NINE_MAX_CONST_I), D3DERR_INVALIDCALL); user_assert(StartRegister + Vector4iCount <= (This->may_swvp ? NINE_MAX_CONST_I_SWVP : NINE_MAX_CONST_I), @@ -3448,6 +3462,7 @@ NineDevice9_GetVertexShaderConstantB( struct NineDevice9 *This, const struct nine_state *state = &This->state; int i; + user_assert(!This->pure, D3DERR_INVALIDCALL); user_assert(StartRegister < (This->may_swvp ? NINE_MAX_CONST_B_SWVP : NINE_MAX_CONST_B), D3DERR_INVALIDCALL); user_assert(StartRegister + BoolCount <= (This->may_swvp ? NINE_MAX_CONST_B_SWVP : NINE_MAX_CONST_B), @@ -3713,6 +3728,7 @@ NineDevice9_GetPixelShaderConstantF( struct NineDevice9 *This, { const struct nine_state *state = &This->state; + user_assert(!This->pure, D3DERR_INVALIDCALL); user_assert(StartRegister < NINE_MAX_CONST_F_PS3, D3DERR_INVALIDCALL); user_assert(StartRegister + Vector4fCount <= NINE_MAX_CONST_F_PS3, D3DERR_INVALIDCALL); user_assert(pConstantData, D3DERR_INVALIDCALL); @@ -3777,6 +3793,7 @@ NineDevice9_GetPixelShaderConstantI( struct NineDevice9 *This, const struct nine_state *state = &This->state; int i; + user_assert(!This->pure, D3DERR_INVALIDCALL); user_assert(StartRegister < NINE_MAX_CONST_I, D3DERR_INVALIDCALL); user_assert(StartRegister + Vector4iCount <= NINE_MAX_CONST_I, D3DERR_INVALIDCALL); user_assert(pConstantData, D3DERR_INVALIDCALL); @@ -3846,6 +3863,7 @@ NineDevice9_GetPixelShaderConstantB( struct NineDevice9 *This, const struct nine_state *state = &This->state; int i; + user_assert(!This->pure, D3DERR_INVALIDCALL); user_assert(StartRegister < NINE_MAX_CONST_B, D3DERR_INVALIDCALL); user_assert(StartRegister + BoolCount <= NINE_MAX_CONST_B, D3DERR_INVALIDCALL); user_assert(pConstantData, D3DERR_INVALIDCALL); diff --git a/src/gallium/frontends/nine/device9.h b/src/gallium/frontends/nine/device9.h index f24d79295ad..1116e2c5ed0 100644 --- a/src/gallium/frontends/nine/device9.h +++ b/src/gallium/frontends/nine/device9.h @@ -158,6 +158,8 @@ struct NineDevice9 /* software vertex processing */ boolean swvp; + /* pure device */ + boolean pure; }; static inline struct NineDevice9 * NineDevice9( void *data ) -- 2.30.2