[Mesa-dev] [RFC PATCH 21/26] glsl: add ARB_bindless_texture operations
Samuel Pitoiset
samuel.pitoiset at gmail.com
Tue Apr 11 16:48:32 UTC 2017
For explicit pack/unpack conversions.
Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
src/compiler/glsl/ir.cpp | 22 ++++++++++++++++++++++
src/compiler/glsl/ir_expression_operation.py | 6 ++++++
src/compiler/glsl/ir_validate.cpp | 20 ++++++++++++++++++++
.../dri/i965/brw_fs_channel_expressions.cpp | 4 ++++
src/mesa/program/ir_to_mesa.cpp | 4 ++++
src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 5 +++++
6 files changed, 61 insertions(+)
diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp
index 019fbe11e5..27e227f228 100644
--- a/src/compiler/glsl/ir.cpp
+++ b/src/compiler/glsl/ir.cpp
@@ -368,6 +368,28 @@ ir_expression::ir_expression(int op, ir_rvalue *op0)
this->type = glsl_type::vec4_type;
break;
+ case ir_unop_unpack_sampler_2x32:
+ case ir_unop_unpack_image_2x32:
+ this->type = glsl_type::uvec2_type;
+ break;
+
+ case ir_unop_pack_sampler_2x32:
+ this->type = glsl_type::get_sampler_instance(
+ (glsl_sampler_dim)op0->type->sampler_dimensionality,
+ (bool)op0->type->sampler_shadow,
+ (bool)op0->type->sampler_array,
+ (glsl_base_type)op0->type->sampled_type,
+ true);
+ break;
+
+ case ir_unop_pack_image_2x32:
+ this->type = glsl_type::get_image_instance(
+ (glsl_sampler_dim)op0->type->sampler_dimensionality,
+ (bool)op0->type->sampler_array,
+ (glsl_base_type)op0->type->sampled_type,
+ true);
+ break;
+
case ir_unop_frexp_sig:
this->type = op0->type;
break;
diff --git a/src/compiler/glsl/ir_expression_operation.py b/src/compiler/glsl/ir_expression_operation.py
index 1d29560733..435956c8dc 100644
--- a/src/compiler/glsl/ir_expression_operation.py
+++ b/src/compiler/glsl/ir_expression_operation.py
@@ -546,6 +546,12 @@ ir_expression_operation = [
operation("pack_double_2x32", 1, printable_name="packDouble2x32", source_types=(uint_type,), dest_type=double_type, c_expression="memcpy(&data.d[0], &op[0]->value.u[0], sizeof(double))", flags=frozenset((horizontal_operation, non_assign_operation))),
operation("unpack_double_2x32", 1, printable_name="unpackDouble2x32", source_types=(double_type,), dest_type=uint_type, c_expression="memcpy(&data.u[0], &op[0]->value.d[0], sizeof(double))", flags=frozenset((horizontal_operation, non_assign_operation))),
+ # Sampler/Image packing, part of ARB_bindless_texture.
+ operation("pack_sampler_2x32", 1, printable_name="packSampler2x32", source_types=(uint_type,), dest_type=uint64_type, c_expression="memcpy(&data.u64[0], &op[0]->value.u[0], sizeof(uint64_t))", flags=frozenset((horizontal_operation, non_assign_operation))),
+ operation("pack_image_2x32", 1, printable_name="packImage2x32", source_types=(uint_type,), dest_type=uint64_type, c_expression="memcpy(&data.u64[0], &op[0]->value.u[0], sizeof(uint64_t))", flags=frozenset((horizontal_operation, non_assign_operation))),
+ operation("unpack_sampler_2x32", 1, printable_name="unpackSampler2x32", source_types=(uint64_type,), dest_type=uint_type, c_expression="memcpy(&data.u[0], &op[0]->value.u64[0], sizeof(uint64_t))", flags=frozenset((horizontal_operation, non_assign_operation))),
+ operation("unpack_image_2x32", 1, printable_name="unpackImage2x32", source_types=(uint64_type,), dest_type=uint_type, c_expression="memcpy(&data.u[0], &op[0]->value.u64[0], sizeof(uint64_t))", flags=frozenset((horizontal_operation, non_assign_operation))),
+
operation("frexp_sig", 1),
operation("frexp_exp", 1),
diff --git a/src/compiler/glsl/ir_validate.cpp b/src/compiler/glsl/ir_validate.cpp
index 76a4ed17e7..e7137a1c8c 100644
--- a/src/compiler/glsl/ir_validate.cpp
+++ b/src/compiler/glsl/ir_validate.cpp
@@ -477,6 +477,16 @@ ir_validate::visit_leave(ir_expression *ir)
assert(ir->operands[0]->type == glsl_type::uvec2_type);
break;
+ case ir_unop_pack_sampler_2x32:
+ assert(ir->type->base_type == GLSL_TYPE_BINDLESS_SAMPLER);
+ assert(ir->operands[0]->type == glsl_type::uvec2_type);
+ break;
+
+ case ir_unop_pack_image_2x32:
+ assert(ir->type->base_type == GLSL_TYPE_BINDLESS_IMAGE);
+ assert(ir->operands[0]->type == glsl_type::uvec2_type);
+ break;
+
case ir_unop_unpack_snorm_2x16:
case ir_unop_unpack_unorm_2x16:
case ir_unop_unpack_half_2x16:
@@ -505,6 +515,16 @@ ir_validate::visit_leave(ir_expression *ir)
assert(ir->operands[0]->type == glsl_type::uint64_t_type);
break;
+ case ir_unop_unpack_sampler_2x32:
+ assert(ir->type == glsl_type::uvec2_type);
+ assert(ir->operands[0]->type->base_type == GLSL_TYPE_BINDLESS_SAMPLER);
+ break;
+
+ case ir_unop_unpack_image_2x32:
+ assert(ir->type == glsl_type::uvec2_type);
+ assert(ir->operands[0]->type->base_type == GLSL_TYPE_BINDLESS_IMAGE);
+ break;
+
case ir_unop_bitfield_reverse:
assert(ir->operands[0]->type == ir->type);
assert(ir->type->is_integer());
diff --git a/src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp b/src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp
index 76dbc06535..305b8de1a4 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp
@@ -470,6 +470,10 @@ ir_channel_expressions_visitor::visit_leave(ir_assignment *ir)
case ir_unop_vote_eq:
case ir_unop_unpack_int_2x32:
case ir_unop_unpack_uint_2x32:
+ case ir_unop_pack_sampler_2x32:
+ case ir_unop_unpack_sampler_2x32:
+ case ir_unop_pack_image_2x32:
+ case ir_unop_unpack_image_2x32:
unreachable("unsupported");
}
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 79c82faac7..1324296b1b 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -1425,6 +1425,10 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
case ir_unop_unpack_int_2x32:
case ir_unop_pack_uint_2x32:
case ir_unop_unpack_uint_2x32:
+ case ir_unop_pack_sampler_2x32:
+ case ir_unop_unpack_sampler_2x32:
+ case ir_unop_pack_image_2x32:
+ case ir_unop_unpack_image_2x32:
assert(!"not supported");
break;
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 96c08a64f3..8b27bc299f 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -2502,6 +2502,11 @@ glsl_to_tgsi_visitor::visit_expression(ir_expression* ir, st_src_reg *op)
case ir_unop_unpack_snorm_4x8:
case ir_unop_unpack_unorm_4x8:
+ case ir_unop_unpack_sampler_2x32:
+ case ir_unop_pack_sampler_2x32:
+ case ir_unop_unpack_image_2x32:
+ case ir_unop_pack_image_2x32:
+
case ir_quadop_vector:
case ir_binop_vector_extract:
case ir_triop_vector_insert:
--
2.12.2
More information about the mesa-dev
mailing list