From: Neha Bhende Date: Fri, 25 Aug 2017 12:06:41 +0000 (-0700) Subject: svga: Add support for arb_texture_gather X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=252e97ecdf05ad1050823e14e2119fbe0cc266a0;p=mesa.git svga: Add support for arb_texture_gather With sm4_1, we can support single channel 2D or CubeMap textures. This patch exercises this feature. Tested with piglit v2: As per Brian's comment Reviewed-by: Brian Paul Reviewed-by: Charmaine Lee --- diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index b66b560fcc0..a38e062f776 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -349,6 +349,9 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param) case PIPE_CAP_FORCE_PERSAMPLE_INTERP: return sws->have_sm4_1; + case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS: + return sws->have_sm4_1 ? 1 : 0; /* only single-channel textures */ + /* Unsupported features */ case PIPE_CAP_TEXTURE_MIRROR_CLAMP: case PIPE_CAP_TEXTURE_MIRROR_CLAMP_TO_EDGE: @@ -362,7 +365,6 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param) case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT: case PIPE_CAP_QUERY_PIPELINE_STATISTICS: case PIPE_CAP_TGSI_VS_LAYER_VIEWPORT: - case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS: case PIPE_CAP_TEXTURE_GATHER_SM5: case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT: case PIPE_CAP_TEXTURE_QUERY_LOD: diff --git a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c index fa27edcd7cf..b87ac906584 100644 --- a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c +++ b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c @@ -5294,6 +5294,52 @@ emit_tex(struct svga_shader_emitter_v10 *emit, return TRUE; } +/** + * Emit code for TGSI_OPCODE_TG4 (texture lookup for texture gather) + */ +static boolean +emit_tg4(struct svga_shader_emitter_v10 *emit, + const struct tgsi_full_instruction *inst) +{ + const uint unit = inst->Src[2].Register.Index; + unsigned target = inst->Texture.Texture; + struct tgsi_full_src_register coord; + int offsets[3]; + struct tex_swizzle_info swz_info; + + /* check that the sampler returns a float */ + if (!is_valid_tex_instruction(emit, inst)) + return TRUE; + + if (target == TGSI_TEXTURE_CUBE_ARRAY) { + debug_printf("TGSI_TEXTURE_CUBE_ARRAY is not supported\n"); + return TRUE; + } + + begin_tex_swizzle(emit, unit, inst, FALSE, &swz_info); + + get_texel_offsets(emit, inst, offsets); + + coord = setup_texcoord(emit, unit, &inst->Src[0]); + + /* Gather dst, coord, resource, sampler */ + begin_emit_instruction(emit); + emit_sample_opcode(emit, VGPU10_OPCODE_GATHER4, + inst->Instruction.Saturate, offsets); + emit_dst_register(emit, get_tex_swizzle_dst(&swz_info)); + emit_src_register(emit, &coord); + emit_resource_register(emit, unit); + emit_sampler_register(emit, unit); + end_emit_instruction(emit); + + end_tex_swizzle(emit, &swz_info); + + free_temp_indexes(emit); + + return TRUE; +} + + /** * Emit code for TGSI_OPCODE_TEX2 (texture lookup for shadow cube map arrays) @@ -5848,6 +5894,8 @@ emit_vgpu10_instruction(struct svga_shader_emitter_v10 *emit, return emit_issg(emit, inst); case TGSI_OPCODE_TEX: return emit_tex(emit, inst); + case TGSI_OPCODE_TG4: + return emit_tg4(emit, inst); case TGSI_OPCODE_TEX2: return emit_tex2(emit, inst); case TGSI_OPCODE_TXP: