Convert unsigned long to uintptr_t for fixes compiling error on win32/mingw64

```
../src/vrend_renderer.c:5162:75: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
 5162 |                glDrawElementsInstancedBaseVertex(mode, info->count, elsz, (void *)(unsigned long)sub_ctx->ib.offset, info->instance_count, info->index_bias);
```

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
macos/master
Yonggang Luo 3 years ago
parent edf38395d6
commit afebbd233c
  1. 30
      src/vrend_renderer.c
  2. 6
      src/vrend_winsys_egl.c

@ -4297,9 +4297,9 @@ static void vrend_draw_bind_vertex_legacy(struct vrend_context *ctx,
enable_bitmask |= (1 << loc); enable_bitmask |= (1 << loc);
if (util_format_is_pure_integer(ve->base.src_format)) { if (util_format_is_pure_integer(ve->base.src_format)) {
glVertexAttribIPointer(loc, size, ve->type, vbo->base.stride, (void *)(unsigned long)(ve->base.src_offset + vbo->base.buffer_offset)); glVertexAttribIPointer(loc, size, ve->type, vbo->base.stride, (void *)(uintptr_t)(ve->base.src_offset + vbo->base.buffer_offset));
} else { } else {
glVertexAttribPointer(loc, size, ve->type, ve->norm, vbo->base.stride, (void *)(unsigned long)(ve->base.src_offset + vbo->base.buffer_offset)); glVertexAttribPointer(loc, size, ve->type, ve->norm, vbo->base.stride, (void *)(uintptr_t)(ve->base.src_offset + vbo->base.buffer_offset));
} }
glVertexAttribDivisorARB(loc, ve->base.instance_divisor); glVertexAttribDivisorARB(loc, ve->base.instance_divisor);
} }
@ -5073,12 +5073,12 @@ int vrend_draw_vbo(struct vrend_context *ctx,
if (indirect_handle) { if (indirect_handle) {
if (indirect_params_res) if (indirect_params_res)
glMultiDrawArraysIndirectCountARB(mode, (GLvoid const *)(unsigned long)info->indirect.offset, glMultiDrawArraysIndirectCountARB(mode, (GLvoid const *)(uintptr_t)info->indirect.offset,
info->indirect.indirect_draw_count_offset, info->indirect.draw_count, info->indirect.stride); info->indirect.indirect_draw_count_offset, info->indirect.draw_count, info->indirect.stride);
else if (info->indirect.draw_count > 1) else if (info->indirect.draw_count > 1)
glMultiDrawArraysIndirect(mode, (GLvoid const *)(unsigned long)info->indirect.offset, info->indirect.draw_count, info->indirect.stride); glMultiDrawArraysIndirect(mode, (GLvoid const *)(uintptr_t)info->indirect.offset, info->indirect.draw_count, info->indirect.stride);
else else
glDrawArraysIndirect(mode, (GLvoid const *)(unsigned long)info->indirect.offset); glDrawArraysIndirect(mode, (GLvoid const *)(uintptr_t)info->indirect.offset);
} else if (info->instance_count > 0) { } else if (info->instance_count > 0) {
if (info->start_instance > 0) if (info->start_instance > 0)
glDrawArraysInstancedBaseInstance(mode, start, count, info->instance_count, info->start_instance); glDrawArraysInstancedBaseInstance(mode, start, count, info->instance_count, info->start_instance);
@ -5104,31 +5104,31 @@ int vrend_draw_vbo(struct vrend_context *ctx,
if (indirect_handle) { if (indirect_handle) {
if (indirect_params_res) if (indirect_params_res)
glMultiDrawElementsIndirectCountARB(mode, elsz, (GLvoid const *)(unsigned long)info->indirect.offset, glMultiDrawElementsIndirectCountARB(mode, elsz, (GLvoid const *)(uintptr_t)info->indirect.offset,
info->indirect.indirect_draw_count_offset, info->indirect.draw_count, info->indirect.stride); info->indirect.indirect_draw_count_offset, info->indirect.draw_count, info->indirect.stride);
else if (info->indirect.draw_count > 1) else if (info->indirect.draw_count > 1)
glMultiDrawElementsIndirect(mode, elsz, (GLvoid const *)(unsigned long)info->indirect.offset, info->indirect.draw_count, info->indirect.stride); glMultiDrawElementsIndirect(mode, elsz, (GLvoid const *)(uintptr_t)info->indirect.offset, info->indirect.draw_count, info->indirect.stride);
else else
glDrawElementsIndirect(mode, elsz, (GLvoid const *)(unsigned long)info->indirect.offset); glDrawElementsIndirect(mode, elsz, (GLvoid const *)(uintptr_t)info->indirect.offset);
} else if (info->index_bias) { } else if (info->index_bias) {
if (info->instance_count > 0) { if (info->instance_count > 0) {
if (info->start_instance > 0) if (info->start_instance > 0)
glDrawElementsInstancedBaseVertexBaseInstance(mode, info->count, elsz, (void *)(unsigned long)sub_ctx->ib.offset, glDrawElementsInstancedBaseVertexBaseInstance(mode, info->count, elsz, (void *)(uintptr_t)sub_ctx->ib.offset,
info->instance_count, info->index_bias, info->start_instance); info->instance_count, info->index_bias, info->start_instance);
else else
glDrawElementsInstancedBaseVertex(mode, info->count, elsz, (void *)(unsigned long)sub_ctx->ib.offset, info->instance_count, info->index_bias); glDrawElementsInstancedBaseVertex(mode, info->count, elsz, (void *)(uintptr_t)sub_ctx->ib.offset, info->instance_count, info->index_bias);
} else if (info->min_index != 0 || info->max_index != (unsigned)-1) } else if (info->min_index != 0 || info->max_index != (unsigned)-1)
glDrawRangeElementsBaseVertex(mode, info->min_index, info->max_index, info->count, elsz, (void *)(unsigned long)sub_ctx->ib.offset, info->index_bias); glDrawRangeElementsBaseVertex(mode, info->min_index, info->max_index, info->count, elsz, (void *)(uintptr_t)sub_ctx->ib.offset, info->index_bias);
else else
glDrawElementsBaseVertex(mode, info->count, elsz, (void *)(unsigned long)sub_ctx->ib.offset, info->index_bias); glDrawElementsBaseVertex(mode, info->count, elsz, (void *)(uintptr_t)sub_ctx->ib.offset, info->index_bias);
} else if (info->instance_count > 1) { } else if (info->instance_count > 1) {
glDrawElementsInstancedARB(mode, info->count, elsz, (void *)(unsigned long)sub_ctx->ib.offset, info->instance_count); glDrawElementsInstancedARB(mode, info->count, elsz, (void *)(uintptr_t)sub_ctx->ib.offset, info->instance_count);
} else if (info->min_index != 0 || info->max_index != (unsigned)-1) } else if (info->min_index != 0 || info->max_index != (unsigned)-1)
glDrawRangeElements(mode, info->min_index, info->max_index, info->count, elsz, (void *)(unsigned long)sub_ctx->ib.offset); glDrawRangeElements(mode, info->min_index, info->max_index, info->count, elsz, (void *)(uintptr_t)sub_ctx->ib.offset);
else else
glDrawElements(mode, info->count, elsz, (void *)(unsigned long)sub_ctx->ib.offset); glDrawElements(mode, info->count, elsz, (void *)(uintptr_t)sub_ctx->ib.offset);
} }
if (info->primitive_restart) { if (info->primitive_restart) {

@ -496,7 +496,7 @@ int virgl_egl_get_fourcc_for_texture(struct virgl_egl *egl, uint32_t tex_id, uin
} }
image = eglCreateImageKHR(egl->egl_display, eglGetCurrentContext(), EGL_GL_TEXTURE_2D_KHR, image = eglCreateImageKHR(egl->egl_display, eglGetCurrentContext(), EGL_GL_TEXTURE_2D_KHR,
(EGLClientBuffer)(unsigned long)tex_id, NULL); (EGLClientBuffer)(uintptr_t)tex_id, NULL);
if (!image) if (!image)
return EINVAL; return EINVAL;
@ -521,7 +521,7 @@ int virgl_egl_get_fd_for_texture2(struct virgl_egl *egl, uint32_t tex_id, int *f
int ret = EINVAL; int ret = EINVAL;
EGLImageKHR image = eglCreateImageKHR(egl->egl_display, eglGetCurrentContext(), EGLImageKHR image = eglCreateImageKHR(egl->egl_display, eglGetCurrentContext(),
EGL_GL_TEXTURE_2D_KHR, EGL_GL_TEXTURE_2D_KHR,
(EGLClientBuffer)(unsigned long)tex_id, NULL); (EGLClientBuffer)(uintptr_t)tex_id, NULL);
if (!image) if (!image)
return EINVAL; return EINVAL;
if (!has_bit(egl->extension_bits, EGL_MESA_IMAGE_DMA_BUF_EXPORT)) if (!has_bit(egl->extension_bits, EGL_MESA_IMAGE_DMA_BUF_EXPORT))
@ -546,7 +546,7 @@ int virgl_egl_get_fd_for_texture(struct virgl_egl *egl, uint32_t tex_id, int *fd
EGLBoolean success; EGLBoolean success;
int ret; int ret;
image = eglCreateImageKHR(egl->egl_display, eglGetCurrentContext(), EGL_GL_TEXTURE_2D_KHR, image = eglCreateImageKHR(egl->egl_display, eglGetCurrentContext(), EGL_GL_TEXTURE_2D_KHR,
(EGLClientBuffer)(unsigned long)tex_id, NULL); (EGLClientBuffer)(uintptr_t)tex_id, NULL);
if (!image) if (!image)
return EINVAL; return EINVAL;

Loading…
Cancel
Save