X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fcompiler%2Fglsl%2Fglsl_to_nir.cpp;h=29e32cde53cb5d79356c1f2fcfbcfd64b586add3;hb=f63e05ae9ea0be38a8fb2dd0ae8f391b8699e757;hp=5e9544f51b13df4148c7d98367a02626e14ae29c;hpb=3442c9fc3ebd5de2c9d6c0b9ce541f182809fe82;p=mesa.git diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp index 5e9544f51b1..29e32cde53c 100644 --- a/src/compiler/glsl/glsl_to_nir.cpp +++ b/src/compiler/glsl/glsl_to_nir.cpp @@ -133,13 +133,13 @@ static void nir_remap_attributes(nir_shader *shader) { nir_foreach_variable(var, &shader->inputs) { - var->data.location += _mesa_bitcount_64(shader->info.double_inputs_read & + var->data.location += _mesa_bitcount_64(shader->info.vs.double_inputs & BITFIELD64_MASK(var->data.location)); } /* Once the remap is done, reset double_inputs_read, so later it will have * which location/slots are doubles */ - shader->info.double_inputs_read = 0; + shader->info.vs.double_inputs = 0; } nir_shader * @@ -163,7 +163,7 @@ glsl_to_nir(const struct gl_shader_program *shader_prog, * two locations. For instance, if we have in the IR code a dvec3 attr0 in * location 0 and vec4 attr1 in location 1, in NIR attr0 will use * locations/slots 0 and 1, and attr1 will use location/slot 2 */ - if (shader->stage == MESA_SHADER_VERTEX) + if (shader->info.stage == MESA_SHADER_VERTEX) nir_remap_attributes(shader); shader->info.name = ralloc_asprintf(shader, "GLSL%d", shader_prog->Name); @@ -219,7 +219,7 @@ constant_copy(ir_constant *ir, void *mem_ctx) if (ir == NULL) return NULL; - nir_constant *ret = ralloc(mem_ctx, nir_constant); + nir_constant *ret = rzalloc(mem_ctx, nir_constant); const unsigned rows = ir->type->vector_elements; const unsigned cols = ir->type->matrix_columns; @@ -311,7 +311,7 @@ nir_visitor::visit(ir_variable *ir) if (ir->data.mode == ir_var_shader_shared) return; - nir_variable *var = ralloc(shader, nir_variable); + nir_variable *var = rzalloc(shader, nir_variable); var->type = ir->type; var->name = ralloc_strdup(var, ir->name); @@ -322,6 +322,7 @@ nir_visitor::visit(ir_variable *ir) var->data.patch = ir->data.patch; var->data.invariant = ir->data.invariant; var->data.location = ir->data.location; + var->data.stream = ir->data.stream; var->data.compact = false; switch(ir->data.mode) { @@ -341,12 +342,12 @@ nir_visitor::visit(ir_variable *ir) break; case ir_var_shader_in: - if (shader->stage == MESA_SHADER_FRAGMENT && + if (shader->info.stage == MESA_SHADER_FRAGMENT && ir->data.location == VARYING_SLOT_FACE) { /* For whatever reason, GLSL IR makes gl_FrontFacing an input */ var->data.location = SYSTEM_VALUE_FRONT_FACE; var->data.mode = nir_var_system_value; - } else if (shader->stage == MESA_SHADER_GEOMETRY && + } else if (shader->info.stage == MESA_SHADER_GEOMETRY && ir->data.location == VARYING_SLOT_PRIMITIVE_ID) { /* For whatever reason, GLSL IR makes gl_PrimitiveIDIn an input */ var->data.location = SYSTEM_VALUE_PRIMITIVE_ID; @@ -354,7 +355,7 @@ nir_visitor::visit(ir_variable *ir) } else { var->data.mode = nir_var_shader_in; - if (shader->stage == MESA_SHADER_TESS_EVAL && + if (shader->info.stage == MESA_SHADER_TESS_EVAL && (ir->data.location == VARYING_SLOT_TESS_LEVEL_INNER || ir->data.location == VARYING_SLOT_TESS_LEVEL_OUTER)) { var->data.compact = ir->type->without_array()->is_scalar(); @@ -362,17 +363,18 @@ nir_visitor::visit(ir_variable *ir) } /* Mark all the locations that require two slots */ - if (glsl_type_is_dual_slot(glsl_without_array(var->type))) { + if (shader->info.stage == MESA_SHADER_VERTEX && + glsl_type_is_dual_slot(glsl_without_array(var->type))) { for (uint i = 0; i < glsl_count_attribute_slots(var->type, true); i++) { uint64_t bitfield = BITFIELD64_BIT(var->data.location + i); - shader->info.double_inputs_read |= bitfield; + shader->info.vs.double_inputs |= bitfield; } } break; case ir_var_shader_out: var->data.mode = nir_var_shader_out; - if (shader->stage == MESA_SHADER_TESS_CTRL && + if (shader->info.stage == MESA_SHADER_TESS_CTRL && (ir->data.location == VARYING_SLOT_TESS_LEVEL_INNER || ir->data.location == VARYING_SLOT_TESS_LEVEL_OUTER)) { var->data.compact = ir->type->without_array()->is_scalar(); @@ -1165,6 +1167,7 @@ nir_visitor::visit(ir_call *ir) case nir_intrinsic_ballot: { nir_ssa_dest_init(&instr->instr, &instr->dest, ir->return_deref->type->vector_elements, 64, NULL); + instr->num_components = ir->return_deref->type->vector_elements; ir_rvalue *value = (ir_rvalue *) ir->actual_parameters.get_head(); instr->src[0] = nir_src_for_ssa(evaluate_rvalue(value)); @@ -1376,13 +1379,15 @@ nir_visitor::evaluate_rvalue(ir_rvalue* ir) static bool type_is_float(glsl_base_type type) { - return type == GLSL_TYPE_FLOAT || type == GLSL_TYPE_DOUBLE; + return type == GLSL_TYPE_FLOAT || type == GLSL_TYPE_DOUBLE || + type == GLSL_TYPE_FLOAT16; } static bool type_is_signed(glsl_base_type type) { - return type == GLSL_TYPE_INT || type == GLSL_TYPE_INT64; + return type == GLSL_TYPE_INT || type == GLSL_TYPE_INT64 || + type == GLSL_TYPE_INT16; } void @@ -1571,7 +1576,8 @@ nir_visitor::visit(ir_expression *ir) case ir_unop_u642i64: { nir_alu_type src_type = nir_get_nir_type_for_glsl_base_type(types[0]); nir_alu_type dst_type = nir_get_nir_type_for_glsl_base_type(out_type); - result = nir_build_alu(&b, nir_type_conversion_op(src_type, dst_type), + result = nir_build_alu(&b, nir_type_conversion_op(src_type, dst_type, + nir_rounding_mode_undef), srcs[0], NULL, NULL, NULL); /* b2i and b2f don't have fixed bit-size versions so the builder will * just assume 32 and we have to fix it up here. @@ -1635,11 +1641,15 @@ nir_visitor::visit(ir_expression *ir) case ir_unop_unpack_half_2x16: result = nir_unpack_half_2x16(&b, srcs[0]); break; + case ir_unop_pack_sampler_2x32: + case ir_unop_pack_image_2x32: case ir_unop_pack_double_2x32: case ir_unop_pack_int_2x32: case ir_unop_pack_uint_2x32: result = nir_pack_64_2x32(&b, srcs[0]); break; + case ir_unop_unpack_sampler_2x32: + case ir_unop_unpack_image_2x32: case ir_unop_unpack_double_2x32: case ir_unop_unpack_int_2x32: case ir_unop_unpack_uint_2x32: @@ -1799,30 +1809,6 @@ nir_visitor::visit(ir_expression *ir) result = nir_slt(&b, srcs[0], srcs[1]); } break; - case ir_binop_greater: - if (supports_ints) { - if (type_is_float(types[0])) - result = nir_flt(&b, srcs[1], srcs[0]); - else if (type_is_signed(types[0])) - result = nir_ilt(&b, srcs[1], srcs[0]); - else - result = nir_ult(&b, srcs[1], srcs[0]); - } else { - result = nir_slt(&b, srcs[1], srcs[0]); - } - break; - case ir_binop_lequal: - if (supports_ints) { - if (type_is_float(types[0])) - result = nir_fge(&b, srcs[1], srcs[0]); - else if (type_is_signed(types[0])) - result = nir_ige(&b, srcs[1], srcs[0]); - else - result = nir_uge(&b, srcs[1], srcs[0]); - } else { - result = nir_slt(&b, srcs[1], srcs[0]); - } - break; case ir_binop_gequal: if (supports_ints) { if (type_is_float(types[0]))