st/nine: Add checks for pure device
authorAxel Davy <davyaxel0@gmail.com>
Wed, 24 Oct 2018 21:28:28 +0000 (23:28 +0200)
committerMarge Bot <eric+marge@anholt.net>
Fri, 15 May 2020 15:43:57 +0000 (15:43 +0000)
Some Get* functions are forbidden for pure device.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5015>

src/gallium/frontends/nine/device9.c
src/gallium/frontends/nine/device9.h

index c5b5eff128e9024a92bfe7f5cd4be13c0b7a38e8..0d73965f2c41f07f2266a35045eaa2bfba4fe70d 100644 (file)
@@ -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);
index f24d79295ad08d78c5f783c5eb09898ba9738a37..1116e2c5ed043c42149dde433f1d69886e30d1e5 100644 (file)
@@ -158,6 +158,8 @@ struct NineDevice9
 
     /* software vertex processing */
     boolean swvp;
+    /* pure device */
+    boolean pure;
 };
 static inline struct NineDevice9 *
 NineDevice9( void *data )