[Mesa-dev] [PATCH 1/2] st/mesa: don't move ssbo after atomic buffers if we support hw atomics
From: Dave Airlie There is no need to have these overlap if we support hw atomics. Signed-off-by: Dave Airlie --- src/mesa/state_tracker/st_atom_storagebuf.c | 8 +--- src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 14 -- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/mesa/state_tracker/st_atom_storagebuf.c b/src/mesa/state_tracker/st_atom_storagebuf.c index a31a8fd..2c55af3 100644 --- a/src/mesa/state_tracker/st_atom_storagebuf.c +++ b/src/mesa/state_tracker/st_atom_storagebuf.c @@ -47,12 +47,14 @@ st_bind_ssbos(struct st_context *st, struct gl_program *prog, unsigned i; struct pipe_shader_buffer buffers[MAX_SHADER_STORAGE_BUFFERS]; struct gl_program_constants *c; - + int buffer_base; if (!prog || !st->pipe->set_shader_buffers) return; c = &st->ctx->Const.Program[prog->info.stage]; + buffer_base = st->has_hw_atomics ? 0 : c->MaxAtomicBuffers; + for (i = 0; i < prog->info.num_ssbos; i++) { struct gl_buffer_binding *binding; struct st_buffer_object *st_obj; @@ -79,13 +81,13 @@ st_bind_ssbos(struct st_context *st, struct gl_program *prog, sb->buffer_size = 0; } } - st->pipe->set_shader_buffers(st->pipe, shader_type, c->MaxAtomicBuffers, + st->pipe->set_shader_buffers(st->pipe, shader_type, buffer_base, prog->info.num_ssbos, buffers); /* clear out any stale shader buffers */ if (prog->info.num_ssbos < c->MaxShaderStorageBlocks) st->pipe->set_shader_buffers( st->pipe, shader_type, -c->MaxAtomicBuffers + prog->info.num_ssbos, +buffer_base + prog->info.num_ssbos, c->MaxShaderStorageBlocks - prog->info.num_ssbos, NULL); } diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 93b5cc7..a863eb2 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -2128,10 +2128,10 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* ir, st_src_reg *op) case ir_unop_get_buffer_size: { ir_constant *const_offset = ir->operands[0]->as_constant(); + int buf_base = ctx->st->has_hw_atomics ? 0 : ctx->Const.Program[shader->Stage].MaxAtomicBuffers; st_src_reg buffer( PROGRAM_BUFFER, -ctx->Const.Program[shader->Stage].MaxAtomicBuffers + -(const_offset ? const_offset->value.u[0] : 0), +buf_base + (const_offset ? const_offset->value.u[0] : 0), GLSL_TYPE_UINT); if (!const_offset) { buffer.reladdr = ralloc(mem_ctx, st_src_reg); @@ -3352,11 +3352,10 @@ glsl_to_tgsi_visitor::visit_ssbo_intrinsic(ir_call *ir) ir_rvalue *offset = ((ir_instruction *)param)->as_rvalue(); ir_constant *const_block = block->as_constant(); - + int buf_base = st_context(ctx)->has_hw_atomics ? 0 : ctx->Const.Program[shader->Stage].MaxAtomicBuffers; st_src_reg buffer( PROGRAM_BUFFER, - ctx->Const.Program[shader->Stage].MaxAtomicBuffers + - (const_block ? const_block->value.u[0] : 0), + buf_base + (const_block ? const_block->value.u[0] : 0), GLSL_TYPE_UINT); if (!const_block) { @@ -6581,7 +6580,10 @@ st_translate_program( assert(prog->info.num_ssbos <= frag_const->MaxShaderStorageBlocks); for (i = 0; i < prog->info.num_ssbos; i++) { - unsigned index = frag_const->MaxAtomicBuffers + i; + unsigned index = i; + if (!st_context(ctx)->has_hw_atomics) +index += frag_const->MaxAtomicBuffers; + t->buffers[index] = ureg_DECL_buffer(ureg, index, false); } } -- 2.9.5 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/2] st/mesa: don't move ssbo after atomic buffers if we support hw atomics
Reviewed-by: Ilia Mirkin On Thu, Nov 16, 2017 at 9:05 PM, Dave Airlie wrote: > From: Dave Airlie > > There is no need to have these overlap if we support hw atomics. > > Signed-off-by: Dave Airlie > --- > src/mesa/state_tracker/st_atom_storagebuf.c | 8 +--- > src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 14 -- > 2 files changed, 13 insertions(+), 9 deletions(-) > > diff --git a/src/mesa/state_tracker/st_atom_storagebuf.c > b/src/mesa/state_tracker/st_atom_storagebuf.c > index a31a8fd..2c55af3 100644 > --- a/src/mesa/state_tracker/st_atom_storagebuf.c > +++ b/src/mesa/state_tracker/st_atom_storagebuf.c > @@ -47,12 +47,14 @@ st_bind_ssbos(struct st_context *st, struct gl_program > *prog, > unsigned i; > struct pipe_shader_buffer buffers[MAX_SHADER_STORAGE_BUFFERS]; > struct gl_program_constants *c; > - > + int buffer_base; > if (!prog || !st->pipe->set_shader_buffers) >return; > > c = &st->ctx->Const.Program[prog->info.stage]; > > + buffer_base = st->has_hw_atomics ? 0 : c->MaxAtomicBuffers; > + > for (i = 0; i < prog->info.num_ssbos; i++) { >struct gl_buffer_binding *binding; >struct st_buffer_object *st_obj; > @@ -79,13 +81,13 @@ st_bind_ssbos(struct st_context *st, struct gl_program > *prog, > sb->buffer_size = 0; >} > } > - st->pipe->set_shader_buffers(st->pipe, shader_type, c->MaxAtomicBuffers, > + st->pipe->set_shader_buffers(st->pipe, shader_type, buffer_base, > prog->info.num_ssbos, buffers); > /* clear out any stale shader buffers */ > if (prog->info.num_ssbos < c->MaxShaderStorageBlocks) >st->pipe->set_shader_buffers( > st->pipe, shader_type, > -c->MaxAtomicBuffers + prog->info.num_ssbos, > +buffer_base + prog->info.num_ssbos, > c->MaxShaderStorageBlocks - prog->info.num_ssbos, > NULL); > } > diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp > b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp > index 93b5cc7..a863eb2 100644 > --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp > +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp > @@ -2128,10 +2128,10 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* > ir, st_src_reg *op) > > case ir_unop_get_buffer_size: { >ir_constant *const_offset = ir->operands[0]->as_constant(); > + int buf_base = ctx->st->has_hw_atomics ? 0 : > ctx->Const.Program[shader->Stage].MaxAtomicBuffers; >st_src_reg buffer( > PROGRAM_BUFFER, > -ctx->Const.Program[shader->Stage].MaxAtomicBuffers + > -(const_offset ? const_offset->value.u[0] : 0), > +buf_base + (const_offset ? const_offset->value.u[0] : 0), > GLSL_TYPE_UINT); >if (!const_offset) { > buffer.reladdr = ralloc(mem_ctx, st_src_reg); > @@ -3352,11 +3352,10 @@ glsl_to_tgsi_visitor::visit_ssbo_intrinsic(ir_call > *ir) > ir_rvalue *offset = ((ir_instruction *)param)->as_rvalue(); > > ir_constant *const_block = block->as_constant(); > - > + int buf_base = st_context(ctx)->has_hw_atomics ? 0 : > ctx->Const.Program[shader->Stage].MaxAtomicBuffers; > st_src_reg buffer( > PROGRAM_BUFFER, > - ctx->Const.Program[shader->Stage].MaxAtomicBuffers + > - (const_block ? const_block->value.u[0] : 0), > + buf_base + (const_block ? const_block->value.u[0] : 0), > GLSL_TYPE_UINT); > > if (!const_block) { > @@ -6581,7 +6580,10 @@ st_translate_program( > >assert(prog->info.num_ssbos <= frag_const->MaxShaderStorageBlocks); >for (i = 0; i < prog->info.num_ssbos; i++) { > - unsigned index = frag_const->MaxAtomicBuffers + i; > + unsigned index = i; > + if (!st_context(ctx)->has_hw_atomics) > +index += frag_const->MaxAtomicBuffers; > + > t->buffers[index] = ureg_DECL_buffer(ureg, index, false); >} > } > -- > 2.9.5 > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 1/2] st/mesa: don't move ssbo after atomic buffers if we support hw atomics
Reviewed-by: Marek Olšák Marek On Fri, Nov 17, 2017 at 3:05 AM, Dave Airlie wrote: > From: Dave Airlie > > There is no need to have these overlap if we support hw atomics. > > Signed-off-by: Dave Airlie > --- > src/mesa/state_tracker/st_atom_storagebuf.c | 8 +--- > src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 14 -- > 2 files changed, 13 insertions(+), 9 deletions(-) > > diff --git a/src/mesa/state_tracker/st_atom_storagebuf.c > b/src/mesa/state_tracker/st_atom_storagebuf.c > index a31a8fd..2c55af3 100644 > --- a/src/mesa/state_tracker/st_atom_storagebuf.c > +++ b/src/mesa/state_tracker/st_atom_storagebuf.c > @@ -47,12 +47,14 @@ st_bind_ssbos(struct st_context *st, struct gl_program > *prog, > unsigned i; > struct pipe_shader_buffer buffers[MAX_SHADER_STORAGE_BUFFERS]; > struct gl_program_constants *c; > - > + int buffer_base; > if (!prog || !st->pipe->set_shader_buffers) >return; > > c = &st->ctx->Const.Program[prog->info.stage]; > > + buffer_base = st->has_hw_atomics ? 0 : c->MaxAtomicBuffers; > + > for (i = 0; i < prog->info.num_ssbos; i++) { >struct gl_buffer_binding *binding; >struct st_buffer_object *st_obj; > @@ -79,13 +81,13 @@ st_bind_ssbos(struct st_context *st, struct gl_program > *prog, > sb->buffer_size = 0; >} > } > - st->pipe->set_shader_buffers(st->pipe, shader_type, c->MaxAtomicBuffers, > + st->pipe->set_shader_buffers(st->pipe, shader_type, buffer_base, > prog->info.num_ssbos, buffers); > /* clear out any stale shader buffers */ > if (prog->info.num_ssbos < c->MaxShaderStorageBlocks) >st->pipe->set_shader_buffers( > st->pipe, shader_type, > -c->MaxAtomicBuffers + prog->info.num_ssbos, > +buffer_base + prog->info.num_ssbos, > c->MaxShaderStorageBlocks - prog->info.num_ssbos, > NULL); > } > diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp > b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp > index 93b5cc7..a863eb2 100644 > --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp > +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp > @@ -2128,10 +2128,10 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* > ir, st_src_reg *op) > > case ir_unop_get_buffer_size: { >ir_constant *const_offset = ir->operands[0]->as_constant(); > + int buf_base = ctx->st->has_hw_atomics ? 0 : > ctx->Const.Program[shader->Stage].MaxAtomicBuffers; >st_src_reg buffer( > PROGRAM_BUFFER, > -ctx->Const.Program[shader->Stage].MaxAtomicBuffers + > -(const_offset ? const_offset->value.u[0] : 0), > +buf_base + (const_offset ? const_offset->value.u[0] : 0), > GLSL_TYPE_UINT); >if (!const_offset) { > buffer.reladdr = ralloc(mem_ctx, st_src_reg); > @@ -3352,11 +3352,10 @@ glsl_to_tgsi_visitor::visit_ssbo_intrinsic(ir_call > *ir) > ir_rvalue *offset = ((ir_instruction *)param)->as_rvalue(); > > ir_constant *const_block = block->as_constant(); > - > + int buf_base = st_context(ctx)->has_hw_atomics ? 0 : > ctx->Const.Program[shader->Stage].MaxAtomicBuffers; > st_src_reg buffer( > PROGRAM_BUFFER, > - ctx->Const.Program[shader->Stage].MaxAtomicBuffers + > - (const_block ? const_block->value.u[0] : 0), > + buf_base + (const_block ? const_block->value.u[0] : 0), > GLSL_TYPE_UINT); > > if (!const_block) { > @@ -6581,7 +6580,10 @@ st_translate_program( > >assert(prog->info.num_ssbos <= frag_const->MaxShaderStorageBlocks); >for (i = 0; i < prog->info.num_ssbos; i++) { > - unsigned index = frag_const->MaxAtomicBuffers + i; > + unsigned index = i; > + if (!st_context(ctx)->has_hw_atomics) > +index += frag_const->MaxAtomicBuffers; > + > t->buffers[index] = ureg_DECL_buffer(ureg, index, false); >} > } > -- > 2.9.5 > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev