#include "util/u_format.h"
#include "tgsi/tgsi_dump.h"
#include "tgsi/tgsi_parse.h"
+#include "nir/tgsi_to_nir.h"
#include "freedreno_program.h"
if (!so)
return NULL;
- if (cso->type == PIPE_SHADER_IR_NIR) {
- so->nir = cso->ir.nir;
- NIR_PASS_V(so->nir, nir_lower_io, nir_var_all, ir2_glsl_type_size,
+ so->nir = (cso->type == PIPE_SHADER_IR_NIR) ? cso->ir.nir :
+ tgsi_to_nir(cso->tokens, pctx->screen);
+
+ NIR_PASS_V(so->nir, nir_lower_io, nir_var_all, ir2_glsl_type_size,
(nir_lower_io_options)0);
- } else {
- assert(cso->type == PIPE_SHADER_IR_TGSI);
- so->nir = ir2_tgsi_to_nir(cso->tokens, pctx->screen);
- }
if (ir2_optimize_nir(so->nir, true))
goto fail;
if (!so)
return NULL;
- if (cso->type == PIPE_SHADER_IR_NIR) {
- so->nir = cso->ir.nir;
- NIR_PASS_V(so->nir, nir_lower_io, nir_var_all, ir2_glsl_type_size,
+ so->nir = (cso->type == PIPE_SHADER_IR_NIR) ? cso->ir.nir :
+ tgsi_to_nir(cso->tokens, pctx->screen);
+
+ NIR_PASS_V(so->nir, nir_lower_io, nir_var_all, ir2_glsl_type_size,
(nir_lower_io_options)0);
- } else {
- assert(cso->type == PIPE_SHADER_IR_TGSI);
- so->nir = ir2_tgsi_to_nir(cso->tokens, pctx->screen);
- }
if (ir2_optimize_nir(so->nir, true))
goto fail;
*/
#include "ir2_private.h"
-#include "nir/tgsi_to_nir.h"
#include "freedreno_util.h"
#include "fd2_program.h"
.vertex_id_zero_based = true, /* its not implemented anyway */
};
-struct nir_shader *
-ir2_tgsi_to_nir(const struct tgsi_token *tokens,
- struct pipe_screen *screen)
-{
- if (!screen) {
- return tgsi_to_nir_noscreen(tokens, &options);
- }
-
- return tgsi_to_nir(tokens, screen);
-}
-
const nir_shader_compiler_options *
ir2_get_compiler_options(void)
{
{
struct ir2_instr *instr;
nir_const_value *const_offset;
- nir_deref_instr *deref;
unsigned idx;
switch (intr->intrinsic) {
case nir_intrinsic_store_output:
store_output(ctx, intr->src[0], output_slot(ctx, intr), intr->num_components);
break;
- case nir_intrinsic_load_deref:
- deref = nir_src_as_deref(intr->src[0]);
- assert(deref->deref_type == nir_deref_type_var);
- load_input(ctx, &intr->dest, deref->var->data.driver_location);
- break;
- case nir_intrinsic_store_deref:
- deref = nir_src_as_deref(intr->src[0]);
- assert(deref->deref_type == nir_deref_type_var);
- store_output(ctx, intr->src[1], deref->var->data.location, intr->num_components);
- break;
case nir_intrinsic_load_uniform:
const_offset = nir_src_as_const_value(intr->src[0]);
assert(const_offset); /* TODO can be false in ES2? */
continue;
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
- unsigned slot;
- switch (intr->intrinsic) {
- case nir_intrinsic_store_deref: {
- nir_deref_instr *deref = nir_src_as_deref(intr->src[0]);
- assert(deref->deref_type == nir_deref_type_var);
- slot = deref->var->data.location;
- } break;
- case nir_intrinsic_store_output:
- slot = output_slot(ctx, intr);
- break;
- default:
+ if (intr->intrinsic != nir_intrinsic_store_output)
continue;
- }
- if (slot != VARYING_SLOT_POS)
+ if (output_slot(ctx, intr) != VARYING_SLOT_POS)
nir_instr_remove(instr);
}
}