[Mesa-dev] [PATCH v2 13/20] i965/fs: Support compute programs in fs_visitor
Kenneth Graunke
kenneth at whitecape.org
Mon Apr 27 15:18:14 PDT 2015
On Friday, April 24, 2015 04:33:05 PM Jordan Justen wrote:
> v2:
> * Clean out some unneeded code copied from run_fs (krh)
> * Always use NIR
> * Split shader time out into a separate commit
>
> Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
> ---
> src/mesa/drivers/dri/i965/brw_context.c | 2 +
> src/mesa/drivers/dri/i965/brw_fs.cpp | 61 ++++++++++++++++++++++++++--
> src/mesa/drivers/dri/i965/brw_fs.h | 10 +++++
> src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 23 +++++++++++
> 4 files changed, 93 insertions(+), 3 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
> index 9d90360..25b50c7 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -594,6 +594,8 @@ brw_initialize_context_constants(struct brw_context *brw)
> if (brw_env_var_as_boolean("INTEL_USE_NIR", true))
> ctx->Const.ShaderCompilerOptions[MESA_SHADER_FRAGMENT].NirOptions = &nir_options;
>
> + ctx->Const.ShaderCompilerOptions[MESA_SHADER_COMPUTE].NirOptions = &nir_options;
> +
> /* ARB_viewport_array */
> if (brw->gen >= 7 && ctx->API == API_OPENGL_CORE) {
> ctx->Const.MaxViewports = GEN7_NUM_VIEWPORTS;
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
> index 61ee056..24d3fa9 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
> @@ -1719,9 +1719,15 @@ fs_visitor::assign_curb_setup()
> if (dispatch_width == 8) {
> prog_data->dispatch_grf_start_reg = payload.num_regs;
> } else {
> - assert(stage == MESA_SHADER_FRAGMENT);
> - brw_wm_prog_data *prog_data = (brw_wm_prog_data*) this->prog_data;
> - prog_data->dispatch_grf_start_reg_16 = payload.num_regs;
> + if (stage == MESA_SHADER_FRAGMENT) {
> + brw_wm_prog_data *prog_data = (brw_wm_prog_data*) this->prog_data;
> + prog_data->dispatch_grf_start_reg_16 = payload.num_regs;
> + } else if (stage == MESA_SHADER_COMPUTE) {
> + brw_cs_prog_data *prog_data = (brw_cs_prog_data*) this->prog_data;
> + prog_data->dispatch_grf_start_reg_16 = payload.num_regs;
> + } else {
> + unreachable("Unsupported shader type!");
> + }
> }
We should be able to eliminate brw_cs_prog_data::dispatch_grf_start_reg_16
and just use brw_stage_prog_data::dispatch_grf_start_reg (since compute
shaders only use one SIMD mode).
I think you want to simplify this hunk to:
if (stage != MESA_SHADER_FRAGMENT || dispatch_width == 8) {
prog_data->dispatch_grf_start_reg = payload.num_regs;
} else {
brw_wm_prog_data *prog_data = (brw_wm_prog_data*) this->prog_data;
prog_data->dispatch_grf_start_reg_16 = payload.num_regs;
}
>
> prog_data->curb_read_length = ALIGN(stage_prog_data->nr_params, 8) / 8;
> @@ -3726,6 +3732,14 @@ fs_visitor::setup_vs_payload()
> }
>
> void
> +fs_visitor::setup_cs_payload()
> +{
> + assert(brw->gen >= 7);
> +
> + payload.num_regs = 1;
> +}
Are you planning to add more code here? Not sure if it's worth a
helper function. It's probably fine though :)
> +
> +void
> fs_visitor::assign_binding_table_offsets()
> {
> assert(stage == MESA_SHADER_FRAGMENT);
> @@ -4065,6 +4079,47 @@ fs_visitor::run_fs()
> return !failed;
> }
>
> +bool
> +fs_visitor::run_cs()
> +{
> + assert(stage == MESA_SHADER_COMPUTE);
> + assert (shader);
^^^ bonus space
Patches 1-13 are:
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150427/a6d2c7cc/attachment.sig>
More information about the mesa-dev
mailing list