~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to src/gallium/auxiliary/draw/draw_pipe_pstipple.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:
46
46
#include "util/u_pstipple.h"
47
47
#include "util/u_sampler.h"
48
48
 
49
 
#include "tgsi/tgsi_transform.h"
 
49
#include "tgsi/tgsi_parse.h"
50
50
 
51
51
#include "draw_context.h"
52
52
#include "draw_pipe.h"
66
66
   struct pipe_shader_state state;
67
67
   void *driver_fs;
68
68
   void *pstip_fs;
69
 
   uint sampler_unit;
 
69
   unsigned sampler_unit;
70
70
};
71
71
 
72
72
 
80
80
   void *sampler_cso;
81
81
   struct pipe_resource *texture;
82
82
   struct pipe_sampler_view *sampler_view;
83
 
   uint num_samplers;
84
 
   uint num_sampler_views;
 
83
   unsigned num_samplers;
 
84
   unsigned num_sampler_views;
85
85
 
86
86
   /*
87
87
    * Currently bound state
123
123
 * Generate the frag shader we'll use for doing polygon stipple.
124
124
 * This will be the user's shader prefixed with a TEX and KIL instruction.
125
125
 */
126
 
static boolean
 
126
static bool
127
127
generate_pstip_fs(struct pstip_stage *pstip)
128
128
{
129
129
   struct pipe_context *pipe = pstip->pipe;
143
143
                                                             0,
144
144
                                                             wincoord_file);
145
145
      if (pstip_fs.tokens == NULL)
146
 
         return FALSE;
 
146
         return false;
147
147
   } else {
148
148
      pstip_fs.ir.nir = nir_shader_clone(NULL, orig_fs->ir.nir);
149
149
      nir_lower_pstipple_fs(pstip_fs.ir.nir,
158
158
   FREE((void *)pstip_fs.tokens);
159
159
 
160
160
   if (!pstip->fs->pstip_fs)
161
 
      return FALSE;
 
161
      return false;
162
162
 
163
 
   return TRUE;
 
163
   return true;
164
164
}
165
165
 
166
166
 
168
168
 * When we're about to draw our first stipple polygon in a batch, this function
169
169
 * is called to tell the driver to bind our modified fragment shader.
170
170
 */
171
 
static boolean
 
171
static bool
172
172
bind_pstip_fragment_shader(struct pstip_stage *pstip)
173
173
{
174
174
   struct draw_context *draw = pstip->stage.draw;
175
175
   if (!pstip->fs->pstip_fs &&
176
176
       !generate_pstip_fs(pstip))
177
 
      return FALSE;
 
177
      return false;
178
178
 
179
 
   draw->suspend_flushing = TRUE;
 
179
   draw->suspend_flushing = true;
180
180
   pstip->driver_bind_fs_state(pstip->pipe, pstip->fs->pstip_fs);
181
 
   draw->suspend_flushing = FALSE;
182
 
   return TRUE;
 
181
   draw->suspend_flushing = false;
 
182
   return true;
183
183
}
184
184
 
185
185
 
196
196
   struct pstip_stage *pstip = pstip_stage(stage);
197
197
   struct pipe_context *pipe = pstip->pipe;
198
198
   struct draw_context *draw = stage->draw;
199
 
   uint num_samplers;
200
 
   uint num_sampler_views;
 
199
   unsigned num_samplers;
 
200
   unsigned num_sampler_views;
201
201
 
202
202
   assert(stage->draw->rasterizer->poly_stipple_enable);
203
203
 
220
220
 
221
221
   assert(num_samplers <= PIPE_MAX_SAMPLERS);
222
222
 
223
 
   draw->suspend_flushing = TRUE;
 
223
   draw->suspend_flushing = true;
224
224
 
225
225
   pstip->driver_bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT, 0,
226
226
                                     num_samplers, pstip->state.samplers);
229
229
                                   num_sampler_views, 0, false,
230
230
                                   pstip->state.sampler_views);
231
231
 
232
 
   draw->suspend_flushing = FALSE;
 
232
   draw->suspend_flushing = false;
233
233
 
234
234
   /* now really draw first triangle */
235
235
   stage->tri = draw_pipe_passthrough_tri;
248
248
   stage->next->flush(stage->next, flags);
249
249
 
250
250
   /* restore original frag shader, texture, sampler state */
251
 
   draw->suspend_flushing = TRUE;
 
251
   draw->suspend_flushing = true;
252
252
   pstip->driver_bind_fs_state(pipe, pstip->fs ? pstip->fs->driver_fs : NULL);
253
253
 
254
254
   pstip->driver_bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT, 0,
259
259
                                   pstip->num_sampler_views, 0, false,
260
260
                                   pstip->state.sampler_views);
261
261
 
262
 
   draw->suspend_flushing = FALSE;
 
262
   draw->suspend_flushing = false;
263
263
}
264
264
 
265
265
 
466
466
 * into the draw module's pipeline.  This will not be used if the
467
467
 * hardware has native support for polygon stipple.
468
468
 */
469
 
boolean
 
469
bool
470
470
draw_install_pstipple_stage(struct draw_context *draw,
471
471
                            struct pipe_context *pipe)
472
472
{
513
513
   pipe->set_sampler_views = pstip_set_sampler_views;
514
514
   pipe->set_polygon_stipple = pstip_set_polygon_stipple;
515
515
 
516
 
   return TRUE;
 
516
   return true;
517
517
 
518
518
 fail:
519
519
   if (pstip)
520
520
      pstip->stage.destroy(&pstip->stage);
521
521
 
522
 
   return FALSE;
 
522
   return false;
523
523
}