st/nine: Fix volumetexture dtor on ctor failure
[mesa.git] / src / gallium / state_trackers / nine / nine_csmt_helper.h
index a4987253bc6bebe0ed09bdfc29f1d3ab5a1de552..7286cc31140e7600ea6877dfd7c5676ffce42fec 100644 (file)
@@ -233,8 +233,8 @@ name##_rx( struct NineDevice9 *device, struct csmt_instruction *instr ) \
     name##_priv( \
         device ARGS_FOR_CALL( __VA_ARGS__ ) \
     ); \
-    ARGS_FOR_UNBIND( __VA_ARGS__ ) \
     p_atomic_dec(args->counter); \
+    ARGS_FOR_UNBIND( __VA_ARGS__ ) \
     return 0; \
 } \
 \
@@ -346,16 +346,12 @@ name##_priv( struct NineDevice9 *device ARGS_FOR_DECLARATION( __VA_ARGS__ ) )
 
 #define ARG_BIND_REF(x, y) \
         x * _##y ,\
-        args->_##y = NULL; \
-        if (args->_##y != y && args->_##y) \
-            NineUnknown_Unbind((void *)(args->_##y)); \
-        if ( args->_##y != y && y ) \
+        if ( y ) \
             NineUnknown_Bind( (void *)y ); \
-        if ( args->_##y != y ) \
-            args->_##y = y ; ,\
+        args->_##y = y ; ,\
         x *y ,\
         args->_##y,\
-        if (args->_##y != NULL && args->_##y) \
+        if (args->_##y) \
             NineUnknown_Unbind((void *)(args->_##y)); \
         args->_##y = NULL; ,\
         ,\
@@ -406,7 +402,18 @@ name##_priv( struct NineDevice9 *device ARGS_FOR_DECLARATION( __VA_ARGS__ ) )
         ,\
         y
 
-#define ARG_BIND_BUF(x, y) \
+#define ARG_BIND_VBUF(x, y) \
+        x _##y ,\
+        memcpy(&args->_##y , y, sizeof(x)); \
+        args->_##y.buffer.resource = NULL; \
+        pipe_resource_reference(&args->_##y.buffer.resource, y->buffer.resource); ,\
+        x *y ,\
+        &args->_##y ,\
+        pipe_resource_reference(&args->_##y.buffer.resource, NULL); ,\
+        ,\
+        y
+
+#define ARG_BIND_IBUF(x, y) \
         x _##y ,\
         memcpy(&args->_##y , y, sizeof(x)); \
         args->_##y.buffer = NULL; \