summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorErik Faye-Lund <[email protected]>2018-08-06 18:59:06 +0200
committerErik Faye-Lund <[email protected]>2018-08-08 09:35:09 +0200
commit0f450e0cbe65e09127e983e53a6c70a1ad86ba77 (patch)
tree2262e467bb1222e2dafd444e6da0f0f9ce9b4e14 /src/mesa/state_tracker
parentcfe69d0aaafadaaaca98517bc33307fba68197ba (diff)
glsl_to_tgsi: plumb image writable through to driver
The virgl driver cares about the writable-flag on image definitions, because it re-emits GLSL from the TGSI. However, so far it was hardcoded to true in glsl_to_tgsi, which cause problems when virglrenderer is running on top of GLES 3.1, where not all formats are supported for writable images. Signed-off-by: Erik Faye-Lund <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi.cpp19
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi_private.h1
2 files changed, 15 insertions, 5 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index aec53309172..55984ff0c78 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -194,6 +194,7 @@ public:
int images_used;
enum tgsi_texture_type image_targets[PIPE_MAX_SHADER_IMAGES];
enum pipe_format image_formats[PIPE_MAX_SHADER_IMAGES];
+ bool image_wr[PIPE_MAX_SHADER_IMAGES];
bool indirect_addr_consts;
int wpos_transform_const;
@@ -3678,7 +3679,8 @@ glsl_to_tgsi_visitor::visit_shared_intrinsic(ir_call *ir)
static void
get_image_qualifiers(ir_dereference *ir, const glsl_type **type,
bool *memory_coherent, bool *memory_volatile,
- bool *memory_restrict, unsigned *image_format)
+ bool *memory_restrict, bool *memory_read_only,
+ unsigned *image_format)
{
switch (ir->ir_type) {
@@ -3694,6 +3696,8 @@ get_image_qualifiers(ir_dereference *ir, const glsl_type **type,
struct_type->fields.structure[fild_idx].memory_volatile;
*memory_restrict =
struct_type->fields.structure[fild_idx].memory_restrict;
+ *memory_read_only =
+ struct_type->fields.structure[fild_idx].memory_read_only;
*image_format =
struct_type->fields.structure[fild_idx].image_format;
break;
@@ -3703,7 +3707,7 @@ get_image_qualifiers(ir_dereference *ir, const glsl_type **type,
ir_dereference_array *deref_arr = ir->as_dereference_array();
get_image_qualifiers((ir_dereference *)deref_arr->array, type,
memory_coherent, memory_volatile, memory_restrict,
- image_format);
+ memory_read_only, image_format);
break;
}
@@ -3714,6 +3718,7 @@ get_image_qualifiers(ir_dereference *ir, const glsl_type **type,
*memory_coherent = var->data.memory_coherent;
*memory_volatile = var->data.memory_volatile;
*memory_restrict = var->data.memory_restrict;
+ *memory_read_only = var->data.memory_read_only;
*image_format = var->data.image_format;
break;
}
@@ -3731,12 +3736,13 @@ glsl_to_tgsi_visitor::visit_image_intrinsic(ir_call *ir)
ir_dereference *img = (ir_dereference *)param;
const ir_variable *imgvar = img->variable_referenced();
unsigned sampler_array_size = 1, sampler_base = 0;
- bool memory_coherent = false, memory_volatile = false, memory_restrict = false;
+ bool memory_coherent = false, memory_volatile = false,
+ memory_restrict = false, memory_read_only = false;
unsigned image_format = 0;
const glsl_type *type = NULL;
get_image_qualifiers(img, &type, &memory_coherent, &memory_volatile,
- &memory_restrict, &image_format);
+ &memory_restrict, &memory_read_only, &image_format);
st_src_reg reladdr;
st_src_reg image(PROGRAM_IMAGE, 0, GLSL_TYPE_UINT);
@@ -3875,6 +3881,7 @@ glsl_to_tgsi_visitor::visit_image_intrinsic(ir_call *ir)
inst->tex_target = type->sampler_index();
inst->image_format = st_mesa_format_to_pipe_format(st_context(ctx),
_mesa_get_shader_image_format(image_format));
+ inst->read_only = memory_read_only;
if (memory_coherent)
inst->buffer_access |= TGSI_MEMORY_COHERENT;
@@ -4675,6 +4682,7 @@ count_resources(glsl_to_tgsi_visitor *v, gl_program *prog)
v->image_targets[idx] =
st_translate_texture_target(inst->tex_target, false);
v->image_formats[idx] = inst->image_format;
+ v->image_wr[idx] = !inst->read_only;
}
}
}
@@ -6770,7 +6778,8 @@ st_translate_program(
t->images[i] = ureg_DECL_image(ureg, i,
program->image_targets[i],
program->image_formats[i],
- true, false);
+ program->image_wr[i],
+ false);
}
}
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_private.h b/src/mesa/state_tracker/st_glsl_to_tgsi_private.h
index fccb7041cfb..356d029f470 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi_private.h
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_private.h
@@ -145,6 +145,7 @@ public:
unsigned tex_offset_num_offset:3;
unsigned dead_mask:4; /**< Used in dead code elimination */
unsigned buffer_access:3; /**< bitmask of TGSI_MEMORY_x bits */
+ unsigned read_only:1;
const struct tgsi_opcode_info *info;