[Mesa-dev] [PATCH 3/8] glsl: Extend ir_expression_operation for ARB_shading_language_packing

Matt Turner mattst88 at gmail.com
Thu Jan 24 19:47:28 PST 2013


For each function {pack,unpack}{Snorm,Unorm}4x8, add a corresponding
opcode to enum ir_expression_operation. Validate the new opcodes in
ir_validate.cpp.
---
 src/glsl/ir.cpp                 |   11 +++++++++++
 src/glsl/ir.h                   |    4 ++++
 src/glsl/ir_validate.cpp        |   12 ++++++++++++
 src/mesa/program/ir_to_mesa.cpp |    4 ++++
 4 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index d80ee3a..a105008 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -316,7 +316,9 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
       break;
 
    case ir_unop_pack_snorm_2x16:
+   case ir_unop_pack_snorm_4x8:
    case ir_unop_pack_unorm_2x16:
+   case ir_unop_pack_unorm_4x8:
    case ir_unop_pack_half_2x16:
       this->type = glsl_type::uint_type;
       break;
@@ -327,6 +329,11 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
       this->type = glsl_type::vec2_type;
       break;
 
+   case ir_unop_unpack_snorm_4x8:
+   case ir_unop_unpack_unorm_4x8:
+      this->type = glsl_type::vec4_type;
+      break;
+
    default:
       assert(!"not reached: missing automatic type setup for ir_expression");
       this->type = op0->type;
@@ -478,10 +485,14 @@ static const char *const operator_strs[] = {
    "dFdx",
    "dFdy",
    "packSnorm2x16",
+   "packSnorm4x8",
    "packUnorm2x16",
+   "packUnorm4x8",
    "packHalf2x16",
    "unpackSnorm2x16",
+   "unpackSnorm4x8",
    "unpackUnorm2x16",
+   "unpackUnorm4x8",
    "unpackHalf2x16",
    "unpackHalf2x16_split_x",
    "unpackHalf2x16_split_y",
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index c1fbe7c..8d8f1c8 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -974,10 +974,14 @@ enum ir_expression_operation {
     */
    /*@{*/
    ir_unop_pack_snorm_2x16,
+   ir_unop_pack_snorm_4x8,
    ir_unop_pack_unorm_2x16,
+   ir_unop_pack_unorm_4x8,
    ir_unop_pack_half_2x16,
    ir_unop_unpack_snorm_2x16,
+   ir_unop_unpack_snorm_4x8,
    ir_unop_unpack_unorm_2x16,
+   ir_unop_unpack_unorm_4x8,
    ir_unop_unpack_half_2x16,
    /*@}*/
 
diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
index 9019637..bc53ea2 100644
--- a/src/glsl/ir_validate.cpp
+++ b/src/glsl/ir_validate.cpp
@@ -336,6 +336,12 @@ ir_validate::visit_leave(ir_expression *ir)
       assert(ir->operands[0]->type == glsl_type::vec2_type);
       break;
 
+   case ir_unop_pack_snorm_4x8:
+   case ir_unop_pack_unorm_4x8:
+      assert(ir->type == glsl_type::uint_type);
+      assert(ir->operands[0]->type == glsl_type::vec4_type);
+      break;
+
    case ir_unop_unpack_snorm_2x16:
    case ir_unop_unpack_unorm_2x16:
    case ir_unop_unpack_half_2x16:
@@ -343,6 +349,12 @@ ir_validate::visit_leave(ir_expression *ir)
       assert(ir->operands[0]->type == glsl_type::uint_type);
       break;
 
+   case ir_unop_unpack_snorm_4x8:
+   case ir_unop_unpack_unorm_4x8:
+      assert(ir->type == glsl_type::vec4_type);
+      assert(ir->operands[0]->type == glsl_type::uint_type);
+      break;
+
    case ir_unop_unpack_half_2x16_split_x:
    case ir_unop_unpack_half_2x16_split_y:
       assert(ir->type == glsl_type::float_type);
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 1ed357a..ec26804 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -1428,10 +1428,14 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
       emit(ir, OPCODE_FRC, result_dst, op[0]);
       break;
    case ir_unop_pack_snorm_2x16:
+   case ir_unop_pack_snorm_4x8:
    case ir_unop_pack_unorm_2x16:
+   case ir_unop_pack_unorm_4x8:
    case ir_unop_pack_half_2x16:
    case ir_unop_unpack_snorm_2x16:
+   case ir_unop_unpack_snorm_4x8:
    case ir_unop_unpack_unorm_2x16:
+   case ir_unop_unpack_unorm_4x8:
    case ir_unop_unpack_half_2x16:
    case ir_unop_unpack_half_2x16_split_x:
    case ir_unop_unpack_half_2x16_split_y:
-- 
1.7.8.6



More information about the mesa-dev mailing list