~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to src/gallium/auxiliary/nir/nir_draw_helpers.c

  • Committer: mmach
  • Date: 2023-11-02 21:31:35 UTC
  • Revision ID: netbit73@gmail.com-20231102213135-18d4tzh7tj0uz752
2023-11-02 22:11:57

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
static nir_ssa_def *
51
51
load_frag_coord(nir_builder *b)
52
52
{
53
 
   nir_foreach_shader_in_variable(var, b->shader) {
54
 
      if (var->data.location == VARYING_SLOT_POS)
55
 
         return nir_load_var(b, var);
56
 
   }
57
 
 
58
 
   nir_variable *pos = nir_variable_create(b->shader, nir_var_shader_in,
59
 
                                           glsl_vec4_type(), NULL);
60
 
   pos->data.location = VARYING_SLOT_POS;
 
53
   nir_variable *pos = nir_get_variable_with_location(b->shader, nir_var_shader_in,
 
54
                                                      VARYING_SLOT_POS, glsl_vec4_type());
61
55
   pos->data.interpolation = INTERP_MODE_NOPERSPECTIVE;
62
 
   pos->data.driver_location = b->shader->num_inputs++;
63
56
   return nir_load_var(b, pos);
64
57
}
65
58
 
74
67
 
75
68
   nir_ssa_def *frag_coord = state->fs_pos_is_sysval ? nir_load_frag_coord(b) : load_frag_coord(b);
76
69
 
77
 
   texcoord = nir_fmul(b, nir_channels(b, frag_coord, 0x3),
 
70
   texcoord = nir_fmul(b, nir_trim_vector(b, frag_coord, 2),
78
71
                       nir_imm_vec2(b, 1.0/32.0, 1.0/32.0));
79
72
 
80
73
   nir_tex_instr *tex = nir_tex_instr_create(b->shader, 1);
84
77
   tex->dest_type = nir_type_float32;
85
78
   tex->texture_index = state->stip_tex->data.binding;
86
79
   tex->sampler_index = state->stip_tex->data.binding;
87
 
   tex->src[0].src_type = nir_tex_src_coord;
88
 
   tex->src[0].src = nir_src_for_ssa(texcoord);
89
 
   nir_ssa_dest_init(&tex->instr, &tex->dest, 4, 32, NULL);
 
80
   tex->src[0] = nir_tex_src_for_ssa(nir_tex_src_coord, texcoord);
 
81
   nir_ssa_dest_init(&tex->instr, &tex->dest, 4, 32);
90
82
 
91
83
   nir_builder_instr_insert(b, &tex->instr);
92
84
 
94
86
 
95
87
   switch (state->bool_type) {
96
88
   case nir_type_bool1:
97
 
      condition = nir_fneu(b, nir_channel(b, &tex->dest.ssa, 3),
98
 
                           nir_imm_floatN_t(b, 0.0, tex->dest.ssa.bit_size));
 
89
      condition = nir_fneu_imm(b, nir_channel(b, &tex->dest.ssa, 3), 0.0);
99
90
      break;
100
91
   case nir_type_bool32:
101
92
      condition = nir_fneu32(b, nir_channel(b, &tex->dest.ssa, 3),
113
104
nir_lower_pstipple_impl(nir_function_impl *impl,
114
105
                        lower_pstipple *state)
115
106
{
116
 
   nir_builder *b = &state->b;
117
 
 
118
 
   nir_builder_init(b, impl);
 
107
   state->b = nir_builder_create(impl);
119
108
 
120
109
   nir_block *start = nir_start_block(impl);
121
110
   nir_lower_pstipple_block(start, state);
159
148
   BITSET_SET(shader->info.samplers_used, binding);
160
149
   state.stip_tex = tex_var;
161
150
 
162
 
   nir_foreach_function(function, shader) {
163
 
      if (function->impl) {
164
 
         nir_lower_pstipple_impl(function->impl, &state);
165
 
      }
 
151
   nir_foreach_function_impl(impl, shader) {
 
152
      nir_lower_pstipple_impl(impl, &state);
166
153
   }
167
154
   *samplerUnitOut = binding;
168
155
}
225
212
 
226
213
      // vec2 a = vec2((uvec2(pattern) >> p) & uvec2(1u));
227
214
      nir_ssa_def *a = nir_i2f32(b,
228
 
         nir_iand(b, nir_ishr(b, nir_vec2(b, pattern, pattern), p),
 
215
         nir_iand(b, nir_ishr(b, nir_replicate(b, pattern, 2), p),
229
216
                  nir_imm_ivec2(b, 1, 1)));
230
217
 
231
218
      // float cov = mix(a.x, a.y, t);
324
311
nir_lower_aapoint_impl(nir_function_impl *impl, lower_aapoint *state,
325
312
                       nir_alu_type bool_type)
326
313
{
327
 
   nir_builder *b = &state->b;
328
 
 
329
 
   nir_builder_init(b, impl);
330
 
 
331
314
   nir_block *block = nir_start_block(impl);
332
 
   b->cursor = nir_before_block(block);
 
315
   state->b = nir_builder_at(nir_before_block(block));
333
316
 
 
317
   nir_builder *b = &state->b;
334
318
   nir_ssa_def *aainput = nir_load_var(b, state->input);
335
319
 
336
320
   nir_ssa_def *dist = nir_fadd(b, nir_fmul(b, nir_channel(b, aainput, 0), nir_channel(b, aainput, 0)),
449
433
   *varying = tgsi_get_generic_gl_varying_index(aapoint_input->data.location, true);
450
434
   state.input = aapoint_input;
451
435
 
452
 
   nir_foreach_function(function, shader) {
453
 
      if (function->impl) {
454
 
         nir_lower_aapoint_impl(function->impl, &state, bool_type);
455
 
      }
 
436
   nir_foreach_function_impl(impl, shader) {
 
437
      nir_lower_aapoint_impl(impl, &state, bool_type);
456
438
   }
457
439
}