st/nine: Fix volumetexture dtor on ctor failure
[mesa.git] / src / gallium / state_trackers / nine / pixelshader9.c
index 92980afe5d6aba4f6466b026982c47bde269a0b3..5d79019a1bcd7a991ba62e9564849fdc85e29d2f 100644 (file)
@@ -51,7 +51,6 @@ NinePixelShader9_ctor( struct NinePixelShader9 *This,
         return D3D_OK;
     }
     device = This->base.device;
-    pipe = NineDevice9_GetPipe(device);
 
     info.type = PIPE_SHADER_FRAGMENT;
     info.byte_code = pFunction;
@@ -63,7 +62,9 @@ NinePixelShader9_ctor( struct NinePixelShader9 *This,
     info.projected = 0;
     info.process_vertices = false;
 
+    pipe = nine_context_get_pipe_acquire(device);
     hr = nine_translate_shader(device, &info, pipe);
+    nine_context_get_pipe_release(device);
     if (FAILED(hr))
         return hr;
     This->byte_code.version = info.version;
@@ -94,7 +95,7 @@ NinePixelShader9_dtor( struct NinePixelShader9 *This )
     DBG("This=%p\n", This);
 
     if (This->base.device) {
-        struct pipe_context *pipe = NineDevice9_GetPipe(This->base.device);
+        struct pipe_context *pipe = nine_context_get_pipe_multithread(This->base.device);
         struct nine_shader_variant *var = &This->variant;
 
         do {
@@ -163,7 +164,7 @@ NinePixelShader9_GetVariant( struct NinePixelShader9 *This )
         info.const_b_base = NINE_CONST_B_BASE(device->max_ps_const_f) / 16;
         info.byte_code = This->byte_code.tokens;
         info.sampler_mask_shadow = key & 0xffff;
-        info.sampler_ps1xtypes = key;
+        info.sampler_ps1xtypes = (key >> 16) & 0xffff;
         info.fog_enable = device->context.rs[D3DRS_FOGENABLE];
         info.fog_mode = device->context.rs[D3DRS_FOGTABLEMODE];
         info.force_color_in_centroid = key >> 34 & 1;
@@ -202,5 +203,9 @@ NinePixelShader9_new( struct NineDevice9 *pDevice,
                       struct NinePixelShader9 **ppOut,
                       const DWORD *pFunction, void *cso )
 {
-    NINE_DEVICE_CHILD_NEW(PixelShader9, ppOut, pDevice, pFunction, cso);
+    if (cso) { /* ff shader. Needs to start with bind count */
+        NINE_DEVICE_CHILD_BIND_NEW(PixelShader9, ppOut, pDevice, pFunction, cso);
+    } else {
+        NINE_DEVICE_CHILD_NEW(PixelShader9, ppOut, pDevice, pFunction, cso);
+    }
 }