Re: [Mesa-dev] [PATCH 1/2] mesa/st: add support for dynamic ubo selection

2014-07-15 Thread Ilia Mirkin
On Wed, Jul 9, 2014 at 9:06 AM, Brian Paul bri...@vmware.com wrote:
 On 07/08/2014 08:40 PM, Ilia Mirkin wrote:

 Signed-off-by: Ilia Mirkin imir...@alum.mit.edu
 ---

 With ChrisF's patches to add support for this in core mesa, this generates
 code like:

 FRAG
 DCL OUT[0], COLOR
 DCL CONST[0]
 DCL CONST[1][0]
 DCL CONST[2][0]
 DCL CONST[3][0]
 DCL CONST[4][0]
 DCL TEMP[0], LOCAL
 DCL ADDR[0..1]
 IMM[0] UINT32 {0, 0, 0, 0}
 IMM[1] INT32 {1, 0, 0, 0}
0: UADD TEMP[0].x, CONST[0]., IMM[1].
1: UARL ADDR[1].x, TEMP[0].
2: UARL ADDR[1].x, TEMP[0].
3: MOV TEMP[0], CONST[ADDR[1].x][0]
4: MOV OUT[0], TEMP[0]
5: END

 Not sure what the deal is with the two UARL's, but nouveau's backend
 removes
 one of them pretty easily. I assume others handle this too.


 Yeah, I noticed this too when I was doing some UBO work last week.  I
 haven't had time to investigate yet.

Does this change look good though? Looks like Chris's non-const UBO
indexing patches are ~ready. With some tweaks to the nvc0 logic, the
simple tests pass on nouveau (and there are no 'complex' tests).


 -Brian



 Unfortunately the core patches aren't quite ready yet, but this patch
 doesn't
 regress anything.

   src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 20 +---
   1 file changed, 17 insertions(+), 3 deletions(-)

 diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
 b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
 index 9bc7500..3202c56 100644
 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
 +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
 @@ -1947,16 +1947,16 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
 break;

  case ir_binop_ubo_load: {
 -  ir_constant *uniform_block = ir-operands[0]-as_constant();
 +  ir_constant *const_uniform_block = ir-operands[0]-as_constant();
 ir_constant *const_offset_ir = ir-operands[1]-as_constant();
 unsigned const_offset = const_offset_ir ?
 const_offset_ir-value.u[0] : 0;
 +  unsigned const_block = const_uniform_block ?
 const_uniform_block-value.u[0] + 1 : 0;
 st_src_reg index_reg = get_temp(glsl_type::uint_type);
 st_src_reg cbuf;

 cbuf.type = glsl_type::vec4_type-base_type;
 cbuf.file = PROGRAM_CONSTANT;
 cbuf.index = 0;
 -  cbuf.index2D = uniform_block-value.u[0] + 1;
 cbuf.reladdr = NULL;
 cbuf.negate = 0;

 @@ -1966,7 +1966,6 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
/* Constant index into constant buffer */
cbuf.reladdr = NULL;
cbuf.index = const_offset / 16;
 - cbuf.has_index2 = true;
 }
 else {
/* Relative/variable index into constant buffer */
 @@ -1976,6 +1975,21 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
memcpy(cbuf.reladdr, index_reg, sizeof(index_reg));
 }

 +  if (const_uniform_block) {
 + /* Constant constant buffer */
 + cbuf.reladdr2 = NULL;
 + cbuf.index2D = const_block;
 + cbuf.has_index2 = true;
 +  }
 +  else {
 + /* Relative/variable constant buffer */
 + emit(ir, TGSI_OPCODE_UADD, st_dst_reg(index_reg), op[0],
 +  st_src_reg_for_int(1));
 + cbuf.reladdr2 = ralloc(mem_ctx, st_src_reg);
 + memcpy(cbuf.reladdr2, index_reg, sizeof(index_reg));
 + cbuf.has_index2 = true;
 +  }
 +
 cbuf.swizzle = swizzle_for_size(ir-type-vector_elements);
 cbuf.swizzle += MAKE_SWIZZLE4(const_offset % 16 / 4,
   const_offset % 16 / 4,


 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] mesa/st: add support for dynamic ubo selection

2014-07-15 Thread Brian Paul

On 07/15/2014 05:28 AM, Ilia Mirkin wrote:

On Wed, Jul 9, 2014 at 9:06 AM, Brian Paul bri...@vmware.com wrote:

On 07/08/2014 08:40 PM, Ilia Mirkin wrote:


Signed-off-by: Ilia Mirkin imir...@alum.mit.edu
---

With ChrisF's patches to add support for this in core mesa, this generates
code like:

FRAG
DCL OUT[0], COLOR
DCL CONST[0]
DCL CONST[1][0]
DCL CONST[2][0]
DCL CONST[3][0]
DCL CONST[4][0]
DCL TEMP[0], LOCAL
DCL ADDR[0..1]
IMM[0] UINT32 {0, 0, 0, 0}
IMM[1] INT32 {1, 0, 0, 0}
0: UADD TEMP[0].x, CONST[0]., IMM[1].
1: UARL ADDR[1].x, TEMP[0].
2: UARL ADDR[1].x, TEMP[0].
3: MOV TEMP[0], CONST[ADDR[1].x][0]
4: MOV OUT[0], TEMP[0]
5: END

Not sure what the deal is with the two UARL's, but nouveau's backend
removes
one of them pretty easily. I assume others handle this too.



Yeah, I noticed this too when I was doing some UBO work last week.  I
haven't had time to investigate yet.


Does this change look good though? Looks like Chris's non-const UBO
indexing patches are ~ready. With some tweaks to the nvc0 logic, the
simple tests pass on nouveau (and there are no 'complex' tests).


I'm not an expert on this code, but look OK AFAICT.

Reviewed-by: Brian Paul bri...@vmware.com






-Brian




Unfortunately the core patches aren't quite ready yet, but this patch
doesn't
regress anything.

   src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 20 +---
   1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 9bc7500..3202c56 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -1947,16 +1947,16 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
 break;

  case ir_binop_ubo_load: {
-  ir_constant *uniform_block = ir-operands[0]-as_constant();
+  ir_constant *const_uniform_block = ir-operands[0]-as_constant();
 ir_constant *const_offset_ir = ir-operands[1]-as_constant();
 unsigned const_offset = const_offset_ir ?
const_offset_ir-value.u[0] : 0;
+  unsigned const_block = const_uniform_block ?
const_uniform_block-value.u[0] + 1 : 0;
 st_src_reg index_reg = get_temp(glsl_type::uint_type);
 st_src_reg cbuf;

 cbuf.type = glsl_type::vec4_type-base_type;
 cbuf.file = PROGRAM_CONSTANT;
 cbuf.index = 0;
-  cbuf.index2D = uniform_block-value.u[0] + 1;
 cbuf.reladdr = NULL;
 cbuf.negate = 0;

@@ -1966,7 +1966,6 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
/* Constant index into constant buffer */
cbuf.reladdr = NULL;
cbuf.index = const_offset / 16;
- cbuf.has_index2 = true;
 }
 else {
/* Relative/variable index into constant buffer */
@@ -1976,6 +1975,21 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
memcpy(cbuf.reladdr, index_reg, sizeof(index_reg));
 }

+  if (const_uniform_block) {
+ /* Constant constant buffer */
+ cbuf.reladdr2 = NULL;
+ cbuf.index2D = const_block;
+ cbuf.has_index2 = true;
+  }
+  else {
+ /* Relative/variable constant buffer */
+ emit(ir, TGSI_OPCODE_UADD, st_dst_reg(index_reg), op[0],
+  st_src_reg_for_int(1));
+ cbuf.reladdr2 = ralloc(mem_ctx, st_src_reg);
+ memcpy(cbuf.reladdr2, index_reg, sizeof(index_reg));
+ cbuf.has_index2 = true;
+  }
+
 cbuf.swizzle = swizzle_for_size(ir-type-vector_elements);
 cbuf.swizzle += MAKE_SWIZZLE4(const_offset % 16 / 4,
   const_offset % 16 / 4,



___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/mesa-devk=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0Ar=lGQMzzTgII0I7jefp2FHq7WtZ%2BTLs8wadB%2BiIj9xpBY%3D%0Am=2PxC4euC4MUhdxrARICGkoYmsaKgMNJkIz%2BtzTOqBt0%3D%0As=d21974c40a550eabfa7fea826f13ec3c3f1e9a1f0fd99ad856975bac472793b5


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] mesa/st: add support for dynamic ubo selection

2014-07-09 Thread Brian Paul

On 07/08/2014 08:40 PM, Ilia Mirkin wrote:

Signed-off-by: Ilia Mirkin imir...@alum.mit.edu
---

With ChrisF's patches to add support for this in core mesa, this generates
code like:

FRAG
DCL OUT[0], COLOR
DCL CONST[0]
DCL CONST[1][0]
DCL CONST[2][0]
DCL CONST[3][0]
DCL CONST[4][0]
DCL TEMP[0], LOCAL
DCL ADDR[0..1]
IMM[0] UINT32 {0, 0, 0, 0}
IMM[1] INT32 {1, 0, 0, 0}
   0: UADD TEMP[0].x, CONST[0]., IMM[1].
   1: UARL ADDR[1].x, TEMP[0].
   2: UARL ADDR[1].x, TEMP[0].
   3: MOV TEMP[0], CONST[ADDR[1].x][0]
   4: MOV OUT[0], TEMP[0]
   5: END

Not sure what the deal is with the two UARL's, but nouveau's backend removes
one of them pretty easily. I assume others handle this too.


Yeah, I noticed this too when I was doing some UBO work last week.  I 
haven't had time to investigate yet.


-Brian



Unfortunately the core patches aren't quite ready yet, but this patch doesn't
regress anything.

  src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 20 +---
  1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 9bc7500..3202c56 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -1947,16 +1947,16 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
break;

 case ir_binop_ubo_load: {
-  ir_constant *uniform_block = ir-operands[0]-as_constant();
+  ir_constant *const_uniform_block = ir-operands[0]-as_constant();
ir_constant *const_offset_ir = ir-operands[1]-as_constant();
unsigned const_offset = const_offset_ir ? const_offset_ir-value.u[0] : 
0;
+  unsigned const_block = const_uniform_block ? 
const_uniform_block-value.u[0] + 1 : 0;
st_src_reg index_reg = get_temp(glsl_type::uint_type);
st_src_reg cbuf;

cbuf.type = glsl_type::vec4_type-base_type;
cbuf.file = PROGRAM_CONSTANT;
cbuf.index = 0;
-  cbuf.index2D = uniform_block-value.u[0] + 1;
cbuf.reladdr = NULL;
cbuf.negate = 0;

@@ -1966,7 +1966,6 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
   /* Constant index into constant buffer */
   cbuf.reladdr = NULL;
   cbuf.index = const_offset / 16;
- cbuf.has_index2 = true;
}
else {
   /* Relative/variable index into constant buffer */
@@ -1976,6 +1975,21 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
   memcpy(cbuf.reladdr, index_reg, sizeof(index_reg));
}

+  if (const_uniform_block) {
+ /* Constant constant buffer */
+ cbuf.reladdr2 = NULL;
+ cbuf.index2D = const_block;
+ cbuf.has_index2 = true;
+  }
+  else {
+ /* Relative/variable constant buffer */
+ emit(ir, TGSI_OPCODE_UADD, st_dst_reg(index_reg), op[0],
+  st_src_reg_for_int(1));
+ cbuf.reladdr2 = ralloc(mem_ctx, st_src_reg);
+ memcpy(cbuf.reladdr2, index_reg, sizeof(index_reg));
+ cbuf.has_index2 = true;
+  }
+
cbuf.swizzle = swizzle_for_size(ir-type-vector_elements);
cbuf.swizzle += MAKE_SWIZZLE4(const_offset % 16 / 4,
  const_offset % 16 / 4,



___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/2] mesa/st: add support for dynamic ubo selection

2014-07-08 Thread Ilia Mirkin
Signed-off-by: Ilia Mirkin imir...@alum.mit.edu
---

With ChrisF's patches to add support for this in core mesa, this generates
code like:

FRAG
DCL OUT[0], COLOR
DCL CONST[0]
DCL CONST[1][0]
DCL CONST[2][0]
DCL CONST[3][0]
DCL CONST[4][0]
DCL TEMP[0], LOCAL
DCL ADDR[0..1]
IMM[0] UINT32 {0, 0, 0, 0}
IMM[1] INT32 {1, 0, 0, 0}
  0: UADD TEMP[0].x, CONST[0]., IMM[1].
  1: UARL ADDR[1].x, TEMP[0].
  2: UARL ADDR[1].x, TEMP[0].
  3: MOV TEMP[0], CONST[ADDR[1].x][0]
  4: MOV OUT[0], TEMP[0]
  5: END

Not sure what the deal is with the two UARL's, but nouveau's backend removes
one of them pretty easily. I assume others handle this too.

Unfortunately the core patches aren't quite ready yet, but this patch doesn't
regress anything.

 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 20 +---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 9bc7500..3202c56 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -1947,16 +1947,16 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
   break;
 
case ir_binop_ubo_load: {
-  ir_constant *uniform_block = ir-operands[0]-as_constant();
+  ir_constant *const_uniform_block = ir-operands[0]-as_constant();
   ir_constant *const_offset_ir = ir-operands[1]-as_constant();
   unsigned const_offset = const_offset_ir ? const_offset_ir-value.u[0] : 
0;
+  unsigned const_block = const_uniform_block ? 
const_uniform_block-value.u[0] + 1 : 0;
   st_src_reg index_reg = get_temp(glsl_type::uint_type);
   st_src_reg cbuf;
 
   cbuf.type = glsl_type::vec4_type-base_type;
   cbuf.file = PROGRAM_CONSTANT;
   cbuf.index = 0;
-  cbuf.index2D = uniform_block-value.u[0] + 1;
   cbuf.reladdr = NULL;
   cbuf.negate = 0;
   
@@ -1966,7 +1966,6 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
  /* Constant index into constant buffer */
  cbuf.reladdr = NULL;
  cbuf.index = const_offset / 16;
- cbuf.has_index2 = true;
   }
   else {
  /* Relative/variable index into constant buffer */
@@ -1976,6 +1975,21 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
  memcpy(cbuf.reladdr, index_reg, sizeof(index_reg));
   }
 
+  if (const_uniform_block) {
+ /* Constant constant buffer */
+ cbuf.reladdr2 = NULL;
+ cbuf.index2D = const_block;
+ cbuf.has_index2 = true;
+  }
+  else {
+ /* Relative/variable constant buffer */
+ emit(ir, TGSI_OPCODE_UADD, st_dst_reg(index_reg), op[0],
+  st_src_reg_for_int(1));
+ cbuf.reladdr2 = ralloc(mem_ctx, st_src_reg);
+ memcpy(cbuf.reladdr2, index_reg, sizeof(index_reg));
+ cbuf.has_index2 = true;
+  }
+
   cbuf.swizzle = swizzle_for_size(ir-type-vector_elements);
   cbuf.swizzle += MAKE_SWIZZLE4(const_offset % 16 / 4,
 const_offset % 16 / 4,
-- 
1.8.5.5

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev