vrend: Fix GL_TEXTURE_SWIZZLE_RGBA on GLES

GL_TEXTURE_SWIZZLE_RGBA is not available on GLES

Fixes: 4ab4d4e ("vrend: pass texture swizzle as array")

Signed-off-by: Lepton Wu <lepton@chromium.org>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
macos/master
Lepton Wu 4 years ago
parent 8d824b10cc
commit 51f45f343b
  1. 12
      src/vrend_renderer.c

@ -2218,6 +2218,11 @@ int vrend_create_sampler_view(struct vrend_context *ctx,
glTexParameteri(view->target, GL_TEXTURE_BASE_LEVEL, base_level); glTexParameteri(view->target, GL_TEXTURE_BASE_LEVEL, base_level);
glTexParameteri(view->target, GL_TEXTURE_MAX_LEVEL, max_level); glTexParameteri(view->target, GL_TEXTURE_MAX_LEVEL, max_level);
if (vrend_state.use_gles) {
for (unsigned int i = 0; i < 4; ++i) {
glTexParameteri(view->target, GL_TEXTURE_SWIZZLE_R + i, view->gl_swizzle[i]);
}
} else
glTexParameteriv(view->target, GL_TEXTURE_SWIZZLE_RGBA, view->gl_swizzle); glTexParameteriv(view->target, GL_TEXTURE_SWIZZLE_RGBA, view->gl_swizzle);
if (util_format_is_srgb(view->format) && if (util_format_is_srgb(view->format) &&
has_feature(feat_texture_srgb_decode)) { has_feature(feat_texture_srgb_decode)) {
@ -2971,6 +2976,13 @@ void vrend_set_single_sampler_view(struct vrend_context *ctx,
tex->cur_max = max_level; tex->cur_max = max_level;
} }
if (memcmp(tex->cur_swizzle, view->gl_swizzle, 4 * sizeof(GLint))) { if (memcmp(tex->cur_swizzle, view->gl_swizzle, 4 * sizeof(GLint))) {
if (vrend_state.use_gles) {
for (unsigned int i = 0; i < 4; ++i) {
if (tex->cur_swizzle[i] != view->gl_swizzle[i]) {
glTexParameteri(view->texture->target, GL_TEXTURE_SWIZZLE_R + i, view->gl_swizzle[i]);
}
}
} else
glTexParameteriv(view->texture->target, GL_TEXTURE_SWIZZLE_RGBA, view->gl_swizzle); glTexParameteriv(view->texture->target, GL_TEXTURE_SWIZZLE_RGBA, view->gl_swizzle);
memcpy(tex->cur_swizzle, view->gl_swizzle, 4 * sizeof(GLint)); memcpy(tex->cur_swizzle, view->gl_swizzle, 4 * sizeof(GLint));
} }

Loading…
Cancel
Save