formats: Add possiblity to pass format flags to insert functions

Also limit the scope of some variables.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
macos/master
Gert Wollny 6 years ago
parent b6f7b8f5f6
commit 804dab8181
  1. 23
      src/vrend_formats.c
  2. 8
      src/vrend_renderer.c
  3. 5
      src/vrend_renderer.h

@ -297,13 +297,16 @@ static struct vrend_format_table gles_bit10_formats[] = {
static void vrend_add_formats(struct vrend_format_table *table, int num_entries) static void vrend_add_formats(struct vrend_format_table *table, int num_entries)
{ {
int i; int i;
uint32_t binding = 0;
GLuint buffers;
GLuint tex_id, fb_id;
for (i = 0; i < num_entries; i++) { for (i = 0; i < num_entries; i++) {
GLenum status; GLenum status;
bool is_depth = false; bool is_depth = false;
uint32_t flags = 0;
uint32_t binding = 0;
GLuint buffers;
GLuint tex_id, fb_id;
/**/ /**/
glGenTextures(1, &tex_id); glGenTextures(1, &tex_id);
glGenFramebuffers(1, &fb_id); glGenFramebuffers(1, &fb_id);
@ -319,24 +322,24 @@ static void vrend_add_formats(struct vrend_format_table *table, int num_entries)
case UTIL_FORMAT_LAYOUT_S3TC: case UTIL_FORMAT_LAYOUT_S3TC:
if (epoxy_has_gl_extension("GL_S3_s3tc") || if (epoxy_has_gl_extension("GL_S3_s3tc") ||
epoxy_has_gl_extension("GL_EXT_texture_compression_s3tc")) epoxy_has_gl_extension("GL_EXT_texture_compression_s3tc"))
vrend_insert_format(&table[i], VIRGL_BIND_SAMPLER_VIEW); vrend_insert_format(&table[i], VIRGL_BIND_SAMPLER_VIEW, flags);
continue; continue;
case UTIL_FORMAT_LAYOUT_RGTC: case UTIL_FORMAT_LAYOUT_RGTC:
if (epoxy_has_gl_extension("GL_ARB_texture_compression_rgtc") || if (epoxy_has_gl_extension("GL_ARB_texture_compression_rgtc") ||
epoxy_has_gl_extension("GL_EXT_texture_compression_rgtc") ) epoxy_has_gl_extension("GL_EXT_texture_compression_rgtc") )
vrend_insert_format(&table[i], VIRGL_BIND_SAMPLER_VIEW); vrend_insert_format(&table[i], VIRGL_BIND_SAMPLER_VIEW, flags);
continue; continue;
case UTIL_FORMAT_LAYOUT_ETC: case UTIL_FORMAT_LAYOUT_ETC:
if (epoxy_has_gl_extension("GL_OES_compressed_ETC1_RGB8_texture")) if (epoxy_has_gl_extension("GL_OES_compressed_ETC1_RGB8_texture"))
vrend_insert_format(&table[i], VIRGL_BIND_SAMPLER_VIEW); vrend_insert_format(&table[i], VIRGL_BIND_SAMPLER_VIEW, flags);
continue; continue;
case UTIL_FORMAT_LAYOUT_BPTC: case UTIL_FORMAT_LAYOUT_BPTC:
if (epoxy_has_gl_extension("GL_ARB_texture_compression_bptc") || if (epoxy_has_gl_extension("GL_ARB_texture_compression_bptc") ||
epoxy_has_gl_extension("GL_EXT_texture_compression_bptc")) epoxy_has_gl_extension("GL_EXT_texture_compression_bptc"))
vrend_insert_format(&table[i], VIRGL_BIND_SAMPLER_VIEW); vrend_insert_format(&table[i], VIRGL_BIND_SAMPLER_VIEW, flags);
continue; continue;
default: default:
@ -366,7 +369,7 @@ static void vrend_add_formats(struct vrend_format_table *table, int num_entries)
} }
if (entry) { if (entry) {
vrend_insert_format_swizzle(table[i].format, entry, binding, swizzle); vrend_insert_format_swizzle(table[i].format, entry, binding, swizzle, flags);
} }
glDeleteTextures(1, &tex_id); glDeleteTextures(1, &tex_id);
glDeleteFramebuffers(1, &fb_id); glDeleteFramebuffers(1, &fb_id);
@ -402,9 +405,9 @@ static void vrend_add_formats(struct vrend_format_table *table, int num_entries)
glDeleteFramebuffers(1, &fb_id); glDeleteFramebuffers(1, &fb_id);
if (table[i].swizzle[0] != SWIZZLE_INVALID) if (table[i].swizzle[0] != SWIZZLE_INVALID)
vrend_insert_format_swizzle(table[i].format, &table[i], binding, table[i].swizzle); vrend_insert_format_swizzle(table[i].format, &table[i], binding, table[i].swizzle, flags);
else else
vrend_insert_format(&table[i], binding); vrend_insert_format(&table[i], binding, flags);
} }
} }

@ -960,19 +960,21 @@ vrend_shader_state_reference(struct vrend_shader_selector **ptr, struct vrend_sh
} }
void void
vrend_insert_format(struct vrend_format_table *entry, uint32_t bindings) vrend_insert_format(struct vrend_format_table *entry, uint32_t bindings, uint32_t flags)
{ {
tex_conv_table[entry->format] = *entry; tex_conv_table[entry->format] = *entry;
tex_conv_table[entry->format].bindings = bindings; tex_conv_table[entry->format].bindings = bindings;
tex_conv_table[entry->format].flags = flags;
} }
void void
vrend_insert_format_swizzle(int override_format, struct vrend_format_table *entry, uint32_t bindings, uint8_t swizzle[4]) vrend_insert_format_swizzle(int override_format, struct vrend_format_table *entry,
uint32_t bindings, uint8_t swizzle[4], uint32_t flags)
{ {
int i; int i;
tex_conv_table[override_format] = *entry; tex_conv_table[override_format] = *entry;
tex_conv_table[override_format].bindings = bindings; tex_conv_table[override_format].bindings = bindings;
tex_conv_table[override_format].flags = VIRGL_BIND_NEED_SWIZZLE; tex_conv_table[override_format].flags = flags | VIRGL_TEXTURE_NEED_SWIZZLE;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
tex_conv_table[override_format].swizzle[i] = swizzle[i]; tex_conv_table[override_format].swizzle[i] = swizzle[i];
} }

@ -116,10 +116,11 @@ struct vrend_if_cbs {
int vrend_renderer_init(struct vrend_if_cbs *cbs, uint32_t flags); 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(struct vrend_format_table *entry, uint32_t bindings, uint32_t flags);
bool vrend_check_fremabuffer_mixed_color_attachements(void); bool vrend_check_fremabuffer_mixed_color_attachements(void);
void vrend_insert_format_swizzle(int override_format, struct vrend_format_table *entry, uint32_t bindings, uint8_t swizzle[4]); void vrend_insert_format_swizzle(int override_format, struct vrend_format_table *entry,
uint32_t bindings, uint8_t swizzle[4], uint32_t flags);
const struct vrend_format_table *vrend_get_format_table_entry(enum virgl_formats format); const struct vrend_format_table *vrend_get_format_table_entry(enum virgl_formats format);
int vrend_create_shader(struct vrend_context *ctx, int vrend_create_shader(struct vrend_context *ctx,
uint32_t handle, uint32_t handle,

Loading…
Cancel
Save