radeonsi: inline si_pm4_alloc_state
[mesa.git] / src / gallium / drivers / radeonsi / si_state.c
index 46dbca3b200eb64a913cb1f38fa8b2caacb7ccb8..54151eb0d19ed9d19e5dec00f1b19b4f7244df76 100644 (file)
@@ -225,7 +225,7 @@ static void si_update_fb_blend_state(struct si_context *sctx)
        if (blend == NULL)
                return;
 
-       pm4 = si_pm4_alloc_state(sctx);
+       pm4 = CALLOC_STRUCT(si_pm4_state);
        if (pm4 == NULL)
                return;
 
@@ -406,7 +406,7 @@ static void si_set_blend_color(struct pipe_context *ctx,
                               const struct pipe_blend_color *state)
 {
        struct si_context *sctx = (struct si_context *)ctx;
-       struct si_pm4_state *pm4 = si_pm4_alloc_state(sctx);
+       struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state);
 
         if (pm4 == NULL)
                 return;
@@ -427,7 +427,7 @@ static void si_set_clip_state(struct pipe_context *ctx,
                              const struct pipe_clip_state *state)
 {
        struct si_context *sctx = (struct si_context *)ctx;
-       struct si_pm4_state *pm4 = si_pm4_alloc_state(sctx);
+       struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state);
        struct pipe_constant_buffer cb;
 
        if (pm4 == NULL)
@@ -530,7 +530,7 @@ static void si_update_fb_rs_state(struct si_context *sctx)
                return;
        }
 
-       pm4 = si_pm4_alloc_state(sctx);
+       pm4 = CALLOC_STRUCT(si_pm4_state);
 
        if (pm4 == NULL)
                return;
@@ -696,7 +696,7 @@ static void si_delete_rs_state(struct pipe_context *ctx, void *state)
  */
 static void si_update_dsa_stencil_ref(struct si_context *sctx)
 {
-       struct si_pm4_state *pm4 = si_pm4_alloc_state(sctx);
+       struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state);
        struct pipe_stencil_ref *ref = &sctx->stencil_ref;
         struct si_state_dsa *dsa = sctx->queued.named.dsa;
 
@@ -2193,14 +2193,6 @@ static INLINE void si_shader_selector_key(struct pipe_context *ctx,
        struct si_context *sctx = (struct si_context *)ctx;
        memset(key, 0, sizeof(*key));
 
-       if ((sel->type == PIPE_SHADER_VERTEX || sel->type == PIPE_SHADER_GEOMETRY) &&
-           sctx->queued.named.rasterizer) {
-               if (sctx->queued.named.rasterizer->clip_plane_enable & 0xf0)
-                       key->vs.ucps_enabled |= 0x2;
-               if (sctx->queued.named.rasterizer->clip_plane_enable & 0xf)
-                       key->vs.ucps_enabled |= 0x1;
-       }
-
        if (sel->type == PIPE_SHADER_VERTEX) {
                unsigned i;
                if (!sctx->vertex_elements)
@@ -2214,15 +2206,13 @@ static INLINE void si_shader_selector_key(struct pipe_context *ctx,
                        key->vs.gs_used_inputs = sctx->gs_shader->gs_used_inputs;
                }
        } else if (sel->type == PIPE_SHADER_FRAGMENT) {
-               if (sel->info.properties[TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS][0])
-                       key->ps.nr_cbufs = sctx->framebuffer.state.nr_cbufs;
+               if (sel->info.properties[TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS])
+                       key->ps.last_cbuf = MAX2(sctx->framebuffer.state.nr_cbufs, 1) - 1;
                key->ps.export_16bpc = sctx->framebuffer.export_16bpc;
 
                if (sctx->queued.named.rasterizer) {
                        key->ps.color_two_side = sctx->queued.named.rasterizer->two_side;
                        key->ps.flatshade = sctx->queued.named.rasterizer->flatshade;
-                       key->ps.interp_at_sample = sctx->framebuffer.nr_samples > 1 &&
-                                                  sctx->ps_iter_samples == sctx->framebuffer.nr_samples;
 
                        if (sctx->queued.named.blend) {
                                key->ps.alpha_to_one = sctx->queued.named.blend->alpha_to_one &&
@@ -2314,9 +2304,9 @@ static void *si_create_shader_state(struct pipe_context *ctx,
        switch (pipe_shader_type) {
        case PIPE_SHADER_GEOMETRY:
                sel->gs_output_prim =
-                       sel->info.properties[TGSI_PROPERTY_GS_OUTPUT_PRIM][0];
+                       sel->info.properties[TGSI_PROPERTY_GS_OUTPUT_PRIM];
                sel->gs_max_out_vertices =
-                       sel->info.properties[TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES][0];
+                       sel->info.properties[TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES];
 
                for (i = 0; i < sel->info.num_inputs; i++) {
                        unsigned name = sel->info.input_semantic_name[i];
@@ -2375,6 +2365,16 @@ static void si_bind_gs_shader(struct pipe_context *ctx, void *state)
        sctx->gs_shader = sel;
 }
 
+void si_make_dummy_ps(struct si_context *sctx)
+{
+       if (!sctx->dummy_pixel_shader) {
+               sctx->dummy_pixel_shader =
+                       util_make_fragment_cloneinput_shader(&sctx->b.b, 0,
+                                                            TGSI_SEMANTIC_GENERIC,
+                                                            TGSI_INTERPOLATE_CONSTANT);
+       }
+}
+
 static void si_bind_ps_shader(struct pipe_context *ctx, void *state)
 {
        struct si_context *sctx = (struct si_context *)ctx;
@@ -2386,13 +2386,7 @@ static void si_bind_ps_shader(struct pipe_context *ctx, void *state)
 
        /* use a dummy shader if binding a NULL shader */
        if (!sel) {
-               if (!sctx->dummy_pixel_shader) {
-                       sctx->dummy_pixel_shader =
-                               util_make_fragment_cloneinput_shader(&sctx->b.b, 0,
-                                                                    TGSI_SEMANTIC_GENERIC,
-                                                                    TGSI_INTERPOLATE_CONSTANT);
-               }
-
+               si_make_dummy_ps(sctx);
                sel = sctx->dummy_pixel_shader;
        }
 
@@ -2840,7 +2834,7 @@ static void si_set_border_colors(struct si_context *sctx, unsigned count,
        }
 
        if (border_color_table) {
-               struct si_pm4_state *pm4 = si_pm4_alloc_state(sctx);
+               struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state);
 
                uint64_t va_offset = sctx->border_color_table->gpu_address;
 
@@ -3087,7 +3081,7 @@ void si_init_state_functions(struct si_context *sctx)
 
 void si_init_config(struct si_context *sctx)
 {
-       struct si_pm4_state *pm4 = si_pm4_alloc_state(sctx);
+       struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state);
 
        if (pm4 == NULL)
                return;