i965: Get rid of gen7_cs_state.c
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 28 Sep 2017 22:27:46 +0000 (15:27 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Fri, 13 Oct 2017 05:39:29 +0000 (22:39 -0700)
The only thing it was handling was push constants.  We pull the actual
constant upload code into gen6_constant_state.c and the atoms into
genX_state_upload.c.

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/Makefile.sources
src/mesa/drivers/dri/i965/brw_state.h
src/mesa/drivers/dri/i965/gen6_constant_state.c
src/mesa/drivers/dri/i965/gen7_cs_state.c [deleted file]
src/mesa/drivers/dri/i965/genX_state_upload.c
src/mesa/drivers/dri/i965/meson.build

index a701b6a35799ad0478ed84ddd94e401f25e13b4d..053d89b81ecf9bc5780b75295bc54958d755e3ee 100644 (file)
@@ -68,7 +68,6 @@ i965_FILES = \
        gen6_sampler_state.c \
        gen6_sol.c \
        gen6_urb.c \
-       gen7_cs_state.c \
        gen7_l3_state.c \
        gen7_misc_state.c \
        gen7_sol_state.c \
index 97d03515599ab5f65db3b8a3ec3ae6ecfb492862..42769b1deda3b944586f3bbefcf9b0e834f2a8f3 100644 (file)
@@ -247,6 +247,11 @@ brw_upload_pull_constants(struct brw_context *brw,
                           const struct gl_program *prog,
                           struct brw_stage_state *stage_state,
                           const struct brw_stage_prog_data *prog_data);
+void
+brw_upload_cs_push_constants(struct brw_context *brw,
+                             const struct gl_program *prog,
+                             const struct brw_cs_prog_data *cs_prog_data,
+                             struct brw_stage_state *stage_state);
 
 /* gen7_vs_state.c */
 void
index a902c6849afc33d02cbaf979d449adee5fb1407f..b2e357fd9d9cdfcec1db06bbb683d282d9bfc216 100644 (file)
@@ -201,3 +201,77 @@ brw_upload_pull_constants(struct brw_context *brw,
 
    brw->ctx.NewDriverState |= brw_new_constbuf;
 }
+
+/**
+ * Creates a region containing the push constants for the CS on gen7+.
+ *
+ * Push constants are constant values (such as GLSL uniforms) that are
+ * pre-loaded into a shader stage's register space at thread spawn time.
+ *
+ * For other stages, see brw_curbe.c:brw_upload_constant_buffer for the
+ * equivalent gen4/5 code and gen6_vs_state.c:gen6_upload_push_constants for
+ * gen6+.
+ */
+void
+brw_upload_cs_push_constants(struct brw_context *brw,
+                             const struct gl_program *prog,
+                             const struct brw_cs_prog_data *cs_prog_data,
+                             struct brw_stage_state *stage_state)
+{
+   struct gl_context *ctx = &brw->ctx;
+   const struct brw_stage_prog_data *prog_data =
+      (struct brw_stage_prog_data*) cs_prog_data;
+
+   /* Updates the ParamaterValues[i] pointers for all parameters of the
+    * basic type of PROGRAM_STATE_VAR.
+    */
+   /* XXX: Should this happen somewhere before to get our state flag set? */
+   _mesa_load_state_parameters(ctx, prog->Parameters);
+
+   if (cs_prog_data->push.total.size == 0) {
+      stage_state->push_const_size = 0;
+      return;
+   }
+
+
+   gl_constant_value *param = (gl_constant_value*)
+      brw_state_batch(brw, ALIGN(cs_prog_data->push.total.size, 64),
+                      64, &stage_state->push_const_offset);
+   assert(param);
+
+   STATIC_ASSERT(sizeof(gl_constant_value) == sizeof(float));
+
+   if (cs_prog_data->push.cross_thread.size > 0) {
+      gl_constant_value *param_copy = param;
+      assert(cs_prog_data->thread_local_id_index < 0 ||
+             cs_prog_data->thread_local_id_index >=
+                cs_prog_data->push.cross_thread.dwords);
+      for (unsigned i = 0;
+           i < cs_prog_data->push.cross_thread.dwords;
+           i++) {
+         param_copy[i] = *prog_data->param[i];
+      }
+   }
+
+   gl_constant_value thread_id;
+   if (cs_prog_data->push.per_thread.size > 0) {
+      for (unsigned t = 0; t < cs_prog_data->threads; t++) {
+         unsigned dst =
+            8 * (cs_prog_data->push.per_thread.regs * t +
+                 cs_prog_data->push.cross_thread.regs);
+         unsigned src = cs_prog_data->push.cross_thread.dwords;
+         for ( ; src < prog_data->nr_params; src++, dst++) {
+            if (src != cs_prog_data->thread_local_id_index)
+               param[dst] = *prog_data->param[src];
+            else {
+               thread_id.u = t * cs_prog_data->simd_size;
+               param[dst] = thread_id;
+            }
+         }
+      }
+   }
+
+   stage_state->push_const_size =
+      cs_prog_data->push.cross_thread.regs +
+      cs_prog_data->push.per_thread.regs;
+}
diff --git a/src/mesa/drivers/dri/i965/gen7_cs_state.c b/src/mesa/drivers/dri/i965/gen7_cs_state.c
deleted file mode 100644 (file)
index cdd6ad8..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright © 2015 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#include "util/ralloc.h"
-#include "brw_context.h"
-#include "brw_defines.h"
-#include "brw_cs.h"
-#include "brw_wm.h"
-#include "intel_mipmap_tree.h"
-#include "intel_batchbuffer.h"
-#include "brw_state.h"
-#include "program/prog_statevars.h"
-#include "compiler/glsl/ir_uniform.h"
-#include "main/shaderapi.h"
-
-/**
- * Creates a region containing the push constants for the CS on gen7+.
- *
- * Push constants are constant values (such as GLSL uniforms) that are
- * pre-loaded into a shader stage's register space at thread spawn time.
- *
- * For other stages, see brw_curbe.c:brw_upload_constant_buffer for the
- * equivalent gen4/5 code and gen6_vs_state.c:gen6_upload_push_constants for
- * gen6+.
- */
-static void
-brw_upload_cs_push_constants(struct brw_context *brw,
-                             const struct gl_program *prog,
-                             const struct brw_cs_prog_data *cs_prog_data,
-                             struct brw_stage_state *stage_state)
-{
-   struct gl_context *ctx = &brw->ctx;
-   const struct brw_stage_prog_data *prog_data =
-      (struct brw_stage_prog_data*) cs_prog_data;
-
-   /* Updates the ParamaterValues[i] pointers for all parameters of the
-    * basic type of PROGRAM_STATE_VAR.
-    */
-   /* XXX: Should this happen somewhere before to get our state flag set? */
-   _mesa_load_state_parameters(ctx, prog->Parameters);
-
-   if (cs_prog_data->push.total.size == 0) {
-      stage_state->push_const_size = 0;
-      return;
-   }
-
-
-   gl_constant_value *param = (gl_constant_value*)
-      brw_state_batch(brw, ALIGN(cs_prog_data->push.total.size, 64),
-                      64, &stage_state->push_const_offset);
-   assert(param);
-
-   STATIC_ASSERT(sizeof(gl_constant_value) == sizeof(float));
-
-   if (cs_prog_data->push.cross_thread.size > 0) {
-      gl_constant_value *param_copy = param;
-      assert(cs_prog_data->thread_local_id_index < 0 ||
-             cs_prog_data->thread_local_id_index >=
-                cs_prog_data->push.cross_thread.dwords);
-      for (unsigned i = 0;
-           i < cs_prog_data->push.cross_thread.dwords;
-           i++) {
-         param_copy[i] = *prog_data->param[i];
-      }
-   }
-
-   gl_constant_value thread_id;
-   if (cs_prog_data->push.per_thread.size > 0) {
-      for (unsigned t = 0; t < cs_prog_data->threads; t++) {
-         unsigned dst =
-            8 * (cs_prog_data->push.per_thread.regs * t +
-                 cs_prog_data->push.cross_thread.regs);
-         unsigned src = cs_prog_data->push.cross_thread.dwords;
-         for ( ; src < prog_data->nr_params; src++, dst++) {
-            if (src != cs_prog_data->thread_local_id_index)
-               param[dst] = *prog_data->param[src];
-            else {
-               thread_id.u = t * cs_prog_data->simd_size;
-               param[dst] = thread_id;
-            }
-         }
-      }
-   }
-
-   stage_state->push_const_size =
-      cs_prog_data->push.cross_thread.regs +
-      cs_prog_data->push.per_thread.regs;
-}
-
-
-static void
-gen7_upload_cs_push_constants(struct brw_context *brw)
-{
-   struct brw_stage_state *stage_state = &brw->cs.base;
-
-   /* BRW_NEW_COMPUTE_PROGRAM */
-   const struct brw_program *cp =
-      (struct brw_program *) brw->programs[MESA_SHADER_COMPUTE];
-
-   if (cp) {
-      /* BRW_NEW_CS_PROG_DATA */
-      struct brw_cs_prog_data *cs_prog_data =
-         brw_cs_prog_data(brw->cs.base.prog_data);
-
-      _mesa_shader_write_subroutine_indices(&brw->ctx, MESA_SHADER_COMPUTE);
-      brw_upload_cs_push_constants(brw, &cp->program, cs_prog_data,
-                                   stage_state);
-   }
-}
-
-const struct brw_tracked_state gen7_cs_push_constants = {
-   .dirty = {
-      .mesa = _NEW_PROGRAM_CONSTANTS,
-      .brw = BRW_NEW_BATCH |
-             BRW_NEW_BLORP |
-             BRW_NEW_COMPUTE_PROGRAM |
-             BRW_NEW_CS_PROG_DATA,
-   },
-   .emit = gen7_upload_cs_push_constants,
-};
-
-/**
- * Creates a new CS constant buffer reflecting the current CS program's
- * constants, if needed by the CS program.
- */
-static void
-brw_upload_cs_pull_constants(struct brw_context *brw)
-{
-   struct brw_stage_state *stage_state = &brw->cs.base;
-
-   /* BRW_NEW_COMPUTE_PROGRAM */
-   struct brw_program *cp =
-      (struct brw_program *) brw->programs[MESA_SHADER_COMPUTE];
-
-   /* BRW_NEW_CS_PROG_DATA */
-   const struct brw_stage_prog_data *prog_data = brw->cs.base.prog_data;
-
-   _mesa_shader_write_subroutine_indices(&brw->ctx, MESA_SHADER_COMPUTE);
-   /* _NEW_PROGRAM_CONSTANTS */
-   brw_upload_pull_constants(brw, BRW_NEW_SURFACES, &cp->program,
-                             stage_state, prog_data);
-}
-
-const struct brw_tracked_state brw_cs_pull_constants = {
-   .dirty = {
-      .mesa = _NEW_PROGRAM_CONSTANTS,
-      .brw = BRW_NEW_BATCH |
-             BRW_NEW_BLORP |
-             BRW_NEW_COMPUTE_PROGRAM |
-             BRW_NEW_CS_PROG_DATA,
-   },
-   .emit = brw_upload_cs_pull_constants,
-};
index fd9eb17b9f2008e2aee90ccc08f8c6d43cfcec82..2327a1bed199b066de63326bf149e51f1d602b57 100644 (file)
@@ -4096,6 +4096,70 @@ static const struct brw_tracked_state genX(tcs_push_constants) = {
 /* ---------------------------------------------------------------------- */
 
 #if GEN_GEN >= 7
+static void
+genX(upload_cs_push_constants)(struct brw_context *brw)
+{
+   struct brw_stage_state *stage_state = &brw->cs.base;
+
+   /* BRW_NEW_COMPUTE_PROGRAM */
+   const struct brw_program *cp =
+      (struct brw_program *) brw->programs[MESA_SHADER_COMPUTE];
+
+   if (cp) {
+      /* BRW_NEW_CS_PROG_DATA */
+      struct brw_cs_prog_data *cs_prog_data =
+         brw_cs_prog_data(brw->cs.base.prog_data);
+
+      _mesa_shader_write_subroutine_indices(&brw->ctx, MESA_SHADER_COMPUTE);
+      brw_upload_cs_push_constants(brw, &cp->program, cs_prog_data,
+                                   stage_state);
+   }
+}
+
+const struct brw_tracked_state genX(cs_push_constants) = {
+   .dirty = {
+      .mesa = _NEW_PROGRAM_CONSTANTS,
+      .brw = BRW_NEW_BATCH |
+             BRW_NEW_BLORP |
+             BRW_NEW_COMPUTE_PROGRAM |
+             BRW_NEW_CS_PROG_DATA,
+   },
+   .emit = genX(upload_cs_push_constants),
+};
+
+/**
+ * Creates a new CS constant buffer reflecting the current CS program's
+ * constants, if needed by the CS program.
+ */
+static void
+genX(upload_cs_pull_constants)(struct brw_context *brw)
+{
+   struct brw_stage_state *stage_state = &brw->cs.base;
+
+   /* BRW_NEW_COMPUTE_PROGRAM */
+   struct brw_program *cp =
+      (struct brw_program *) brw->programs[MESA_SHADER_COMPUTE];
+
+   /* BRW_NEW_CS_PROG_DATA */
+   const struct brw_stage_prog_data *prog_data = brw->cs.base.prog_data;
+
+   _mesa_shader_write_subroutine_indices(&brw->ctx, MESA_SHADER_COMPUTE);
+   /* _NEW_PROGRAM_CONSTANTS */
+   brw_upload_pull_constants(brw, BRW_NEW_SURFACES, &cp->program,
+                             stage_state, prog_data);
+}
+
+const struct brw_tracked_state genX(cs_pull_constants) = {
+   .dirty = {
+      .mesa = _NEW_PROGRAM_CONSTANTS,
+      .brw = BRW_NEW_BATCH |
+             BRW_NEW_BLORP |
+             BRW_NEW_COMPUTE_PROGRAM |
+             BRW_NEW_CS_PROG_DATA,
+   },
+   .emit = genX(upload_cs_pull_constants),
+};
+
 static void
 genX(upload_cs_state)(struct brw_context *brw)
 {
@@ -5597,8 +5661,8 @@ genX(init_atoms)(struct brw_context *brw)
    {
       &gen7_l3_state,
       &brw_cs_image_surfaces,
-      &gen7_cs_push_constants,
-      &brw_cs_pull_constants,
+      &genX(cs_push_constants),
+      &genX(cs_pull_constants),
       &brw_cs_ubo_surfaces,
       &brw_cs_abo_surfaces,
       &brw_cs_texture_surfaces,
index 0fbad4181a2ccc076154442e403700ed99d09b25..144a254bd6471318b37c380066f49a295381c183 100644 (file)
@@ -88,7 +88,6 @@ files_i965 = files(
   'gen6_sampler_state.c',
   'gen6_sol.c',
   'gen6_urb.c',
-  'gen7_cs_state.c',
   'gen7_l3_state.c',
   'gen7_misc_state.c',
   'gen7_sol_state.c',