From: Dave Airlie Date: Mon, 15 Jun 2020 07:21:27 +0000 (+1000) Subject: llvmpipe/draw: wire up indirect offset X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d243655d34025f85328a1091ac0e9ef2576bfc93;p=mesa.git llvmpipe/draw: wire up indirect offset This bounds checks and adds to the llvm index. Reviewed-by: Roland Scheidegger Part-of: --- diff --git a/src/gallium/auxiliary/draw/draw_llvm_sample.c b/src/gallium/auxiliary/draw/draw_llvm_sample.c index 76b83730004..faffe42a0d1 100644 --- a/src/gallium/auxiliary/draw/draw_llvm_sample.c +++ b/src/gallium/auxiliary/draw/draw_llvm_sample.c @@ -119,6 +119,11 @@ draw_llvm_texture_member(const struct lp_sampler_dynamic_state *base, indices[1] = lp_build_const_int32(gallivm, DRAW_JIT_CTX_TEXTURES); /* context[0].textures[unit] */ indices[2] = lp_build_const_int32(gallivm, texture_unit); + if (texture_unit_offset) { + indices[2] = LLVMBuildAdd(gallivm->builder, indices[2], texture_unit_offset, ""); + LLVMValueRef cond = LLVMBuildICmp(gallivm->builder, LLVMIntULT, indices[2], lp_build_const_int32(gallivm, PIPE_MAX_SHADER_SAMPLER_VIEWS), ""); + indices[2] = LLVMBuildSelect(gallivm->builder, cond, indices[2], lp_build_const_int32(gallivm, texture_unit), ""); + } /* context[0].textures[unit].member */ indices[3] = lp_build_const_int32(gallivm, member_index); @@ -211,6 +216,11 @@ draw_llvm_image_member(const struct lp_sampler_dynamic_state *base, indices[1] = lp_build_const_int32(gallivm, DRAW_JIT_CTX_IMAGES); /* context[0].textures[unit] */ indices[2] = lp_build_const_int32(gallivm, image_unit); + if (image_unit_offset) { + indices[2] = LLVMBuildAdd(gallivm->builder, indices[2], image_unit_offset, ""); + LLVMValueRef cond = LLVMBuildICmp(gallivm->builder, LLVMIntULT, indices[2], lp_build_const_int32(gallivm, PIPE_MAX_SHADER_IMAGES), ""); + indices[2] = LLVMBuildSelect(gallivm->builder, cond, indices[2], lp_build_const_int32(gallivm, image_unit), ""); + } /* context[0].textures[unit].member */ indices[3] = lp_build_const_int32(gallivm, member_index); diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample.c b/src/gallium/drivers/llvmpipe/lp_tex_sample.c index a8d18d772d9..ea44970d0b7 100644 --- a/src/gallium/drivers/llvmpipe/lp_tex_sample.c +++ b/src/gallium/drivers/llvmpipe/lp_tex_sample.c @@ -128,6 +128,11 @@ lp_llvm_texture_member(const struct lp_sampler_dynamic_state *base, indices[1] = lp_build_const_int32(gallivm, LP_JIT_CTX_TEXTURES); /* context[0].textures[unit] */ indices[2] = lp_build_const_int32(gallivm, texture_unit); + if (texture_unit_offset) { + indices[2] = LLVMBuildAdd(gallivm->builder, indices[2], texture_unit_offset, ""); + LLVMValueRef cond = LLVMBuildICmp(gallivm->builder, LLVMIntULT, indices[2], lp_build_const_int32(gallivm, PIPE_MAX_SHADER_SAMPLER_VIEWS), ""); + indices[2] = LLVMBuildSelect(gallivm->builder, cond, indices[2], lp_build_const_int32(gallivm, texture_unit), ""); + } /* context[0].textures[unit].member */ indices[3] = lp_build_const_int32(gallivm, member_index); @@ -275,6 +280,11 @@ lp_llvm_image_member(const struct lp_sampler_dynamic_state *base, indices[1] = lp_build_const_int32(gallivm, LP_JIT_CTX_IMAGES); /* context[0].images[unit] */ indices[2] = lp_build_const_int32(gallivm, image_unit); + if (image_unit_offset) { + indices[2] = LLVMBuildAdd(gallivm->builder, indices[2], image_unit_offset, ""); + LLVMValueRef cond = LLVMBuildICmp(gallivm->builder, LLVMIntULT, indices[2], lp_build_const_int32(gallivm, PIPE_MAX_SHADER_IMAGES), ""); + indices[2] = LLVMBuildSelect(gallivm->builder, cond, indices[2], lp_build_const_int32(gallivm, image_unit), ""); + } /* context[0].images[unit].member */ indices[3] = lp_build_const_int32(gallivm, member_index);