vrend: Ensure non-zero stride and remove redundant check

Ensure we can't create a texture resource with zero width, to
guarantee that we get a non-zero stride, since either:

1. A non-zero stride was specified in the transfer request, or
2. We will calculate a stride based on texture width which we guarantee
   is not zero

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
macos/master
Alexandros Frantzis 5 years ago committed by Gurchetan Singh
parent 23ccf5c1a9
commit 7a0ff8da57
  1. 7
      src/vrend_renderer.c

@ -5977,7 +5977,9 @@ static int vrend_renderer_resource_allocate_texture(struct vrend_resource *gr,
GLenum internalformat, glformat, gltype; GLenum internalformat, glformat, gltype;
struct vrend_texture *gt = (struct vrend_texture *)gr; struct vrend_texture *gt = (struct vrend_texture *)gr;
struct pipe_resource *pr = &gr->base; struct pipe_resource *pr = &gr->base;
assert(pr->width0 > 0);
if (pr->width0 == 0)
return EINVAL;
bool format_can_texture_storage = has_feature(feat_texture_storage) && bool format_can_texture_storage = has_feature(feat_texture_storage) &&
(tex_conv_table[pr->format].flags & VIRGL_TEXTURE_CAN_TEXTURE_STORAGE); (tex_conv_table[pr->format].flags & VIRGL_TEXTURE_CAN_TEXTURE_STORAGE);
@ -6598,7 +6600,8 @@ static int vrend_renderer_transfer_write_iov(struct vrend_context *ctx,
data = (char*)iov[0].iov_base + info->offset; data = (char*)iov[0].iov_base + info->offset;
} }
if (stride && !need_temp) { if (!need_temp) {
assert(stride);
glPixelStorei(GL_UNPACK_ROW_LENGTH, stride / elsize); glPixelStorei(GL_UNPACK_ROW_LENGTH, stride / elsize);
glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, layer_stride / stride); glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, layer_stride / stride);
} else } else

Loading…
Cancel
Save