softpipe: fix texture view crashes
[mesa.git] / src / gallium / drivers / softpipe / sp_image.c
index 0be11cb86402b4eb7b593eeb96e616f203fbbce3..49b775cf0cc6b7e0c20240f67642500c8c7099cf 100644 (file)
@@ -39,7 +39,7 @@ get_image_offset(const struct softpipe_resource *spr,
    int base_layer = 0;
 
    if (spr->base.target == PIPE_BUFFER)
-      return iview->u.buf.first_element * util_format_get_blocksize(format);
+      return iview->u.buf.offset;
 
    if (spr->base.target == PIPE_TEXTURE_1D_ARRAY ||
        spr->base.target == PIPE_TEXTURE_2D_ARRAY ||
@@ -153,7 +153,7 @@ get_dimensions(const struct pipe_image_view *iview,
                unsigned *depth)
 {
    if (tgsi_tex_instr == TGSI_TEXTURE_BUFFER) {
-      *width = iview->u.buf.last_element - iview->u.buf.first_element + 1;
+      *width = iview->u.buf.size / util_format_get_blocksize(pformat);
       *height = 1;
       *depth = 1;
       /*
@@ -384,7 +384,7 @@ handle_op_uint(const struct pipe_image_view *iview,
                char *data_ptr,
                uint qi,
                unsigned stride,
-               unsigned opcode,
+               enum tgsi_opcode opcode,
                int s,
                int t,
                float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE],
@@ -501,7 +501,7 @@ handle_op_int(const struct pipe_image_view *iview,
               char *data_ptr,
               uint qi,
               unsigned stride,
-              unsigned opcode,
+              enum tgsi_opcode opcode,
               int s,
               int t,
               float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE],
@@ -615,7 +615,7 @@ handle_op_r32f_xchg(const struct pipe_image_view *iview,
                     char *data_ptr,
                     uint qi,
                     unsigned stride,
-                    unsigned opcode,
+                    enum tgsi_opcode opcode,
                     int s,
                     int t,
                     float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE])
@@ -649,7 +649,7 @@ handle_op_r32f_xchg(const struct pipe_image_view *iview,
 static void
 sp_tgsi_op(const struct tgsi_image *image,
            const struct tgsi_image_params *params,
-           unsigned opcode,
+           enum tgsi_opcode opcode,
            const int s[TGSI_QUAD_SIZE],
            const int t[TGSI_QUAD_SIZE],
            const int r[TGSI_QUAD_SIZE],
@@ -752,7 +752,7 @@ sp_tgsi_get_dims(const struct tgsi_image *image,
       return;
 
    if (params->tgsi_tex_instr == TGSI_TEXTURE_BUFFER) {
-      dims[0] = iview->u.buf.last_element - iview->u.buf.first_element + 1;
+      dims[0] = iview->u.buf.size / util_format_get_blocksize(iview->format);
       dims[1] = dims[2] = dims[3] = 0;
       return;
    }