vrend: rename internal texture flags and use CAN_TEXTURE_STORAGE correctly

The name for the internal texture properies flags VIRGL_BIND_NEED-SWIZZLE
and VIRGL_BIND_CAN_TEXTURE_STORAGE is misleading, and the latter flag was
even mis-using the binding member of the texture format structure.

Rename these flags to make it clear that these are not binding flags and
correctly use the 'flags' member for CAN_TEXTURE_STORAGE. In addition, drop
adding the NEED_SWIZZLE flag to the binding in the alpha texture emulation.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
macos/master
Gert Wollny 5 years ago
parent 4a4f04827c
commit b6f7b8f5f6
  1. 4
      src/vrend_blitter.c
  2. 4
      src/vrend_formats.c
  3. 10
      src/vrend_renderer.c
  4. 7
      src/vrend_renderer.h

@ -414,7 +414,7 @@ static GLuint blit_get_frag_tex_col(struct vrend_blitter_ctx *blit_ctx,
{
assert(pipe_tex_target < PIPE_MAX_TEXTURE_TYPES);
bool needs_swizzle = dst_entry->flags & VIRGL_BIND_NEED_SWIZZLE;
bool needs_swizzle = dst_entry->flags & VIRGL_TEXTURE_NEED_SWIZZLE;
if (needs_swizzle || nr_samples > 1) {
const uint8_t *swizzle = needs_swizzle ? dst_entry->swizzle : NULL;
@ -809,7 +809,7 @@ void vrend_renderer_blit_gl(struct vrend_context *ctx,
glBindTexture(src_res->target, blit_views[0]);
if (src_entry->flags & VIRGL_BIND_NEED_SWIZZLE) {
if (src_entry->flags & VIRGL_TEXTURE_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,

@ -348,7 +348,7 @@ static void vrend_add_formats(struct vrend_format_table *table, int num_entries)
if (status == GL_INVALID_VALUE || status == GL_INVALID_ENUM || status == GL_INVALID_OPERATION) {
struct vrend_format_table *entry = NULL;
uint8_t swizzle[4];
binding = VIRGL_BIND_SAMPLER_VIEW | VIRGL_BIND_RENDER_TARGET | VIRGL_BIND_NEED_SWIZZLE;
binding = VIRGL_BIND_SAMPLER_VIEW | VIRGL_BIND_RENDER_TARGET;
switch (table[i].format) {
case PIPE_FORMAT_A8_UNORM:
@ -493,7 +493,7 @@ void vrend_check_texture_storage(struct vrend_format_table *table)
glBindTexture(GL_TEXTURE_2D, tex_id);
glTexStorage2D(GL_TEXTURE_2D, 1, table[i].internalformat, 32, 32);
if (glGetError() == GL_NO_ERROR)
table[i].bindings |= VIRGL_BIND_CAN_TEXTURE_STORAGE;
table[i].flags |= VIRGL_TEXTURE_CAN_TEXTURE_STORAGE;
glDeleteTextures(1, &tex_id);
}
}

@ -1636,7 +1636,7 @@ int vrend_create_surface(struct vrend_context *ctx,
if (has_feature(feat_texture_view) &&
res->storage != VREND_RESOURCE_STORAGE_BUFFER &&
(tex_conv_table[res->base.format].bindings & VIRGL_BIND_CAN_TEXTURE_STORAGE)) {
(tex_conv_table[res->base.format].flags & VIRGL_TEXTURE_CAN_TEXTURE_STORAGE)) {
/* We don't need texture views for buffer objects.
* Otherwise we only need a texture view if the
* a) formats differ between the surface and base texture
@ -1926,7 +1926,7 @@ int vrend_create_sampler_view(struct vrend_context *ctx,
swizzle[3] = PIPE_SWIZZLE_ONE;
}
if (tex_conv_table[view->format].flags & VIRGL_BIND_NEED_SWIZZLE) {
if (tex_conv_table[view->format].flags & VIRGL_TEXTURE_NEED_SWIZZLE) {
if (swizzle[0] <= PIPE_SWIZZLE_ALPHA)
swizzle[0] = tex_conv_table[view->format].swizzle[swizzle[0]];
if (swizzle[1] <= PIPE_SWIZZLE_ALPHA)
@ -1970,7 +1970,7 @@ int vrend_create_sampler_view(struct vrend_context *ctx,
format = view->texture->base.format;
else if (view->format != view->texture->base.format)
needs_view = true;
if (needs_view && (tex_conv_table[view->texture->base.format].bindings & VIRGL_BIND_CAN_TEXTURE_STORAGE)) {
if (needs_view && (tex_conv_table[view->texture->base.format].flags & VIRGL_TEXTURE_CAN_TEXTURE_STORAGE)) {
glGenTextures(1, &view->id);
GLenum internalformat = tex_conv_table[format].internalformat;
unsigned base_layer = view->val0 & 0xffff;
@ -5981,7 +5981,7 @@ static int vrend_renderer_resource_allocate_texture(struct vrend_resource *gr,
assert(pr->width0 > 0);
bool format_can_texture_storage = has_feature(feat_texture_storage) &&
(tex_conv_table[pr->format].bindings & VIRGL_BIND_CAN_TEXTURE_STORAGE);
(tex_conv_table[pr->format].flags & VIRGL_TEXTURE_CAN_TEXTURE_STORAGE);
gr->target = tgsitargettogltarget(pr->target, pr->nr_samples);
gr->storage = VREND_RESOURCE_STORAGE_TEXTURE;
@ -7651,7 +7651,7 @@ static GLuint vrend_make_view(struct vrend_resource *res, enum pipe_format forma
GLenum fmt = tex_conv_table[format].internalformat;
/* If the format doesn't support TextureStorage it is not immutable, so no TextureView*/
if (!(tex_conv_table[format].bindings & VIRGL_BIND_CAN_TEXTURE_STORAGE))
if (!(tex_conv_table[format].flags & VIRGL_TEXTURE_CAN_TEXTURE_STORAGE))
return res->id;
VREND_DEBUG(dbg_blit, NULL, "Create texture view from %s for %s\n",

@ -77,9 +77,8 @@ struct vrend_resource {
uint64_t mipmap_offsets[VR_MAX_TEXTURE_2D_LEVELS];
};
#define VIRGL_BIND_NEED_SWIZZLE (1 << 28)
#define VIRGL_BIND_CAN_TEXTURE_STORAGE (1 << 29)
#define VIRGL_TEXTURE_NEED_SWIZZLE (1 << 0)
#define VIRGL_TEXTURE_CAN_TEXTURE_STORAGE (1 << 1)
struct vrend_format_table {
enum virgl_formats format;
@ -88,7 +87,7 @@ struct vrend_format_table {
GLenum gltype;
uint8_t swizzle[4];
uint32_t bindings;
int flags;
uint32_t flags;
};
struct vrend_transfer_info {

Loading…
Cancel
Save