vrend: Use source swizzle when blitting with GL

Use the source format swizzle information to set the
GL_TEXTURE_SWIZZLE_* parameters for the GL blit operation. This also
removes the need for the emulated alpha special case, since when using
emulated alpha the source format already has proper swizzle information.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
macos/master
Alexandros Frantzis 7 years ago committed by Jakob Bornecrantz
parent 84f1a4c8ce
commit 732e68e48d
  1. 30
      src/vrend_blitter.c
  2. 6
      src/vrend_renderer.c
  3. 1
      src/vrend_renderer.h

@ -614,6 +614,21 @@ static void set_dsa_write_depth_keep_stencil(void)
glDepthMask(GL_TRUE);
}
static inline GLenum to_gl_swizzle(int swizzle)
{
switch (swizzle) {
case PIPE_SWIZZLE_RED: return GL_RED;
case PIPE_SWIZZLE_GREEN: return GL_GREEN;
case PIPE_SWIZZLE_BLUE: return GL_BLUE;
case PIPE_SWIZZLE_ALPHA: return GL_ALPHA;
case PIPE_SWIZZLE_ZERO: return GL_ZERO;
case PIPE_SWIZZLE_ONE: return GL_ONE;
default:
assert(0);
return 0;
}
}
/* implement blitting using OpenGL. */
void vrend_renderer_blit_gl(struct vrend_context *ctx,
struct vrend_resource *src_res,
@ -635,6 +650,8 @@ void vrend_renderer_blit_gl(struct vrend_context *ctx,
util_format_description(src_res->base.format);
const struct util_format_description *dst_desc =
util_format_description(dst_res->base.format);
const struct vrend_format_table *src_entry =
vrend_get_format_table_entry(info->src.format);
has_depth = util_format_has_depth(src_desc) &&
util_format_has_depth(dst_desc);
@ -691,8 +708,17 @@ void vrend_renderer_blit_gl(struct vrend_context *ctx,
glBindTexture(src_res->target, src_res->id);
if (vrend_format_is_emulated_alpha(info->src.format))
glTexParameteri(src_res->target, GL_TEXTURE_SWIZZLE_A, GL_RED);
if (src_entry->flags & VREND_BIND_NEED_SWIZZLE) {
glTexParameteri(src_res->target, GL_TEXTURE_SWIZZLE_R,
to_gl_swizzle(src_entry->swizzle[0]));
glTexParameteri(src_res->target, GL_TEXTURE_SWIZZLE_G,
to_gl_swizzle(src_entry->swizzle[1]));
glTexParameteri(src_res->target, GL_TEXTURE_SWIZZLE_B,
to_gl_swizzle(src_entry->swizzle[2]));
glTexParameteri(src_res->target, GL_TEXTURE_SWIZZLE_A,
to_gl_swizzle(src_entry->swizzle[3]));
}
glTexParameteri(src_res->target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(src_res->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

@ -673,6 +673,12 @@ vrend_insert_format_swizzle(int override_format, struct vrend_format_table *entr
tex_conv_table[override_format].swizzle[i] = swizzle[i];
}
const struct vrend_format_table *
vrend_get_format_table_entry(enum virgl_formats format)
{
return &tex_conv_table[format];
}
static bool vrend_is_timer_query(GLenum gltype)
{
return gltype == GL_TIMESTAMP ||

@ -105,6 +105,7 @@ int vrend_renderer_init(struct vrend_if_cbs *cbs, uint32_t flags);
void vrend_insert_format(struct vrend_format_table *entry, uint32_t bindings);
void vrend_insert_format_swizzle(int override_format, struct vrend_format_table *entry, uint32_t bindings, uint8_t swizzle[4]);
const struct vrend_format_table *vrend_get_format_table_entry(enum virgl_formats format);
int vrend_create_shader(struct vrend_context *ctx,
uint32_t handle,
const struct pipe_stream_output_info *stream_output,

Loading…
Cancel
Save