From 3942943819a87ad423df56e3138223fc37f5db21 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Thu, 16 Aug 2018 15:11:12 -0500 Subject: nir: Use a bitfield for image access qualifiers This commit expands the current memory access enum to contain the extra two bits provided for images. We choose to follow the SPIR-V convention of NonReadable and NonWriteable because readonly implies that you *can* read so readonly + writeonly doesn't make as much sense as NonReadable + NonWriteable. Reviewed-by: Kenneth Graunke --- src/compiler/glsl/gl_nir_link_uniforms.c | 12 +++++++----- src/compiler/glsl/glsl_to_nir.cpp | 19 ++++++++++++++----- 2 files changed, 21 insertions(+), 10 deletions(-) (limited to 'src/compiler/glsl') diff --git a/src/compiler/glsl/gl_nir_link_uniforms.c b/src/compiler/glsl/gl_nir_link_uniforms.c index 159dfeca59f..1a491dc2e5d 100644 --- a/src/compiler/glsl/gl_nir_link_uniforms.c +++ b/src/compiler/glsl/gl_nir_link_uniforms.c @@ -424,12 +424,14 @@ nir_link_uniform(struct gl_context *ctx, uniform->opaque[stage].index = image_index; /* Set image access qualifiers */ + enum gl_access_qualifier image_access = + state->current_var->data.image.access; const GLenum access = - state->current_var->data.image.read_only ? - (state->current_var->data.image.write_only ? GL_NONE : - GL_READ_ONLY) : - (state->current_var->data.image.write_only ? GL_WRITE_ONLY : - GL_READ_WRITE); + (image_access & ACCESS_NON_WRITEABLE) ? + ((image_access & ACCESS_NON_READABLE) ? GL_NONE : + GL_READ_ONLY) : + ((image_access & ACCESS_NON_READABLE) ? GL_WRITE_ONLY : + GL_READ_WRITE); for (unsigned i = image_index; i < MIN2(state->next_image_index, MAX_IMAGE_UNIFORMS); i++) { diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp index 22419abc571..f38d280d406 100644 --- a/src/compiler/glsl/glsl_to_nir.cpp +++ b/src/compiler/glsl/glsl_to_nir.cpp @@ -416,12 +416,21 @@ nir_visitor::visit(ir_variable *ir) var->data.explicit_binding = ir->data.explicit_binding; var->data.bindless = ir->data.bindless; var->data.offset = ir->data.offset; - var->data.image.read_only = ir->data.memory_read_only; - var->data.image.write_only = ir->data.memory_write_only; - var->data.image.coherent = ir->data.memory_coherent; - var->data.image._volatile = ir->data.memory_volatile; - var->data.image.restrict_flag = ir->data.memory_restrict; + + unsigned image_access = 0; + if (ir->data.memory_read_only) + image_access |= ACCESS_NON_WRITEABLE; + if (ir->data.memory_write_only) + image_access |= ACCESS_NON_READABLE; + if (ir->data.memory_coherent) + image_access |= ACCESS_COHERENT; + if (ir->data.memory_volatile) + image_access |= ACCESS_VOLATILE; + if (ir->data.memory_restrict) + image_access |= ACCESS_RESTRICT; + var->data.image.access = (gl_access_qualifier)image_access; var->data.image.format = ir->data.image_format; + var->data.fb_fetch_output = ir->data.fb_fetch_output; var->data.explicit_xfb_buffer = ir->data.explicit_xfb_buffer; var->data.explicit_xfb_stride = ir->data.explicit_xfb_stride; -- cgit v1.2.3