glsl: Extend ir_expression_operation for ARB_shading_language_packing
authorMatt Turner <mattst88@gmail.com>
Mon, 21 Jan 2013 22:12:37 +0000 (14:12 -0800)
committerMatt Turner <mattst88@gmail.com>
Fri, 25 Jan 2013 22:10:23 +0000 (14:10 -0800)
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.

Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
src/glsl/ir.cpp
src/glsl/ir.h
src/glsl/ir_validate.cpp
src/mesa/program/ir_to_mesa.cpp

index 4c5115b98cfe54bf78a02b04bdb75233df0a3a3a..954995db387ddf8235241953db83a8c7fafa2309 100644 (file)
@@ -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",
index cb96a200aa97468b4a8c0c015d5880f44cbe9ae3..efd80dad894bd36d553debaeecd679a4b84aca87 100644 (file)
@@ -1009,10 +1009,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,
    /*@}*/
 
index 816f7d3ec109740f89c7f438b57adce5a3aec582..d8cafd55f071990fe5ed13564b58b2760f92b501 100644 (file)
@@ -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);
index b197ad3443784bafe23843cda0abffa67fa20c42..cd89171dabe6eec5e875dfdffc1bdff8f05802ed 100644 (file)
@@ -1432,10 +1432,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: