vrend_shader: do a first pass analyzing tgsi instructions

We can emit them during the second pass.  Since a load
or store can come before an atomic max or min, we have to
type the memory before we emit instructions.

Reviewed-by: Dave Airlie <airlied@redhat.com>
macos/master
Gurchetan Singh 6 years ago committed by Dave Airlie
parent 272d9a4db4
commit b0a4b4ae19
  1. 25
      src/vrend_shader.c

@ -155,6 +155,7 @@ struct dump_ctx {
uint32_t ssbo_atomic_mask; uint32_t ssbo_atomic_mask;
uint32_t ssbo_array_base; uint32_t ssbo_array_base;
uint32_t ssbo_atomic_array_base; uint32_t ssbo_atomic_array_base;
uint32_t ssbo_integer_mask;
struct vrend_shader_image images[32]; struct vrend_shader_image images[32];
uint32_t images_used_mask; uint32_t images_used_mask;
@ -171,6 +172,7 @@ struct dump_ctx {
unsigned fragcoord_input; unsigned fragcoord_input;
uint32_t req_local_mem; uint32_t req_local_mem;
bool integer_memory;
uint32_t num_ubo; uint32_t num_ubo;
int ubo_idx[32]; int ubo_idx[32];
@ -4798,6 +4800,22 @@ static boolean fill_interpolants(struct dump_ctx *ctx, struct vrend_shader_info
return FALSE; return FALSE;
} }
static boolean analyze_instruction(struct tgsi_iterate_context *iter,
struct tgsi_full_instruction *inst)
{
struct dump_ctx *ctx = (struct dump_ctx *)iter;
uint32_t opcode = inst->Instruction.Opcode;
if (opcode == TGSI_OPCODE_ATOMIMIN || opcode == TGSI_OPCODE_ATOMIMAX) {
const struct tgsi_full_src_register *src = &inst->Src[0];
if (src->Register.File == TGSI_FILE_BUFFER)
ctx->ssbo_integer_mask |= 1 << src->Register.Index;
if (src->Register.File == TGSI_FILE_MEMORY)
ctx->integer_memory = true;
}
return true;
}
char *vrend_convert_shader(struct vrend_shader_cfg *cfg, char *vrend_convert_shader(struct vrend_shader_cfg *cfg,
const struct tgsi_token *tokens, const struct tgsi_token *tokens,
uint32_t req_local_mem, uint32_t req_local_mem,
@ -4810,6 +4828,13 @@ char *vrend_convert_shader(struct vrend_shader_cfg *cfg,
char *glsl_hdr = NULL; char *glsl_hdr = NULL;
memset(&ctx, 0, sizeof(struct dump_ctx)); memset(&ctx, 0, sizeof(struct dump_ctx));
/* First pass to deal with edge cases. */
ctx.iter.iterate_instruction = analyze_instruction;
bret = tgsi_iterate_shader(tokens, &ctx.iter);
if (bret == FALSE)
return NULL;
ctx.iter.prolog = prolog; ctx.iter.prolog = prolog;
ctx.iter.iterate_instruction = iter_instruction; ctx.iter.iterate_instruction = iter_instruction;
ctx.iter.iterate_declaration = iter_declaration; ctx.iter.iterate_declaration = iter_declaration;

Loading…
Cancel
Save