diff --git a/src/intel/blorp/blorp_blit.c b/src/intel/blorp/blorp_blit.c index 8e325da23ab..458af08f43e 100644 --- a/src/intel/blorp/blorp_blit.c +++ b/src/intel/blorp/blorp_blit.c @@ -25,6 +25,7 @@ #include "compiler/nir/nir_format_convert.h" #include "blorp_priv.h" +#include "blorp_shaders.h" #include "dev/intel_debug.h" #include "dev/intel_device_info.h" @@ -1285,8 +1286,9 @@ blorp_build_nir_shader(struct blorp_context *blorp, nir_if *bounds_if = NULL; if (key->use_kill) { nir_def *bounds_rect = nir_load_var(&b, v.v_bounds_rect); - nir_def *in_bounds = blorp_check_in_bounds(&b, bounds_rect, - dst_pos); + nir_def *in_bounds = + blorp_check_in_bounds(&b, bounds_rect, + nir_channels(&b, dst_pos, 0x3)); if (!compute) nir_discard_if(&b, nir_inot(&b, in_bounds)); else diff --git a/src/intel/blorp/blorp_clear.c b/src/intel/blorp/blorp_clear.c index 5122902fce8..859ac175da9 100644 --- a/src/intel/blorp/blorp_clear.c +++ b/src/intel/blorp/blorp_clear.c @@ -29,6 +29,7 @@ #include "util/u_math.h" #include "blorp_priv.h" +#include "blorp_shaders.h" #include "dev/intel_debug.h" #include "dev/intel_device_info.h" @@ -165,7 +166,8 @@ blorp_params_get_clear_kernel_cs(struct blorp_batch *batch, nir_variable *v_bounds_rect = BLORP_CREATE_NIR_INPUT(b.shader, clear.bounds_rect, glsl_vec4_type()); nir_def *bounds_rect = nir_load_var(&b, v_bounds_rect); - nir_def *in_bounds = blorp_check_in_bounds(&b, bounds_rect, dst_pos); + nir_def *in_bounds = + blorp_check_in_bounds(&b, bounds_rect, nir_channels(&b, dst_pos, 0x3)); if (clear_rgb_as_red) { nir_def *comp = nir_umod_imm(&b, nir_channel(&b, dst_pos, 0), 3); diff --git a/src/intel/blorp/blorp_nir_builder.h b/src/intel/blorp/blorp_nir_builder.h index 1dbd29b73b8..e3702cbbe78 100644 --- a/src/intel/blorp/blorp_nir_builder.h +++ b/src/intel/blorp/blorp_nir_builder.h @@ -107,24 +107,3 @@ blorp_nir_mcs_is_clear_color(nir_builder *b, UNREACHABLE("Invalid sample count"); } } - -static inline nir_def * -blorp_check_in_bounds(nir_builder *b, - nir_def *bounds_rect, - nir_def *pos) -{ - nir_def *x0 = nir_channel(b, bounds_rect, 0); - nir_def *x1 = nir_channel(b, bounds_rect, 1); - nir_def *y0 = nir_channel(b, bounds_rect, 2); - nir_def *y1 = nir_channel(b, bounds_rect, 3); - - nir_def *c0 = nir_uge(b, nir_channel(b, pos, 0), x0); - nir_def *c1 = nir_ult(b, nir_channel(b, pos, 0), x1); - nir_def *c2 = nir_uge(b, nir_channel(b, pos, 1), y0); - nir_def *c3 = nir_ult(b, nir_channel(b, pos, 1), y1); - - nir_def *in_bounds = - nir_iand(b, nir_iand(b, c0, c1), nir_iand(b, c2, c3)); - - return in_bounds; -} diff --git a/src/intel/blorp/blorp_shaders.cl b/src/intel/blorp/blorp_shaders.cl new file mode 100644 index 00000000000..212f8323b3d --- /dev/null +++ b/src/intel/blorp/blorp_shaders.cl @@ -0,0 +1,38 @@ +/* + * Copyright © 2025 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "compiler/libcl/libcl.h" +#include "compiler/nir/nir_defines.h" +#include "compiler/shader_enums.h" + +bool +blorp_check_in_bounds(uint4 bounds_rect, uint2 pos) +{ + uint x0 = bounds_rect[0]; + uint x1 = bounds_rect[1]; + uint y0 = bounds_rect[2]; + uint y1 = bounds_rect[3]; + + return pos.x >= x0 && pos.x < x1 && + pos.y >= y0 && pos.y < y1; +} diff --git a/src/intel/blorp/meson.build b/src/intel/blorp/meson.build index bf4e2c4b093..1b82cc5ce1f 100644 --- a/src/intel/blorp/meson.build +++ b/src/intel/blorp/meson.build @@ -1,6 +1,37 @@ # Copyright © 2017 Intel Corporation # SPDX-License-Identifier: MIT +blorp_shader_files = files( + 'blorp_shaders.cl', +) + +blorp_shaders_spv = custom_target( + input : blorp_shader_files, + output : 'blorp_shaders.spv', + command : [ + prog_mesa_clc, '-o', '@OUTPUT@', '--depfile', '@DEPFILE@', + blorp_shader_files, '--', + '-I' + join_paths(meson.project_source_root(), 'include'), + '-I' + join_paths(meson.project_source_root(), 'src/compiler/libcl'), + '-I' + join_paths(meson.project_source_root(), 'src'), + '-I' + join_paths(meson.current_source_dir(), '.'), + cl_args, + ], + depends : [gen_cl_xml_pack], + depfile : 'blorp_shaders.h.d', +) + +blorp_shaders = custom_target( + input : blorp_shaders_spv, + output : ['blorp_shaders.cpp', 'blorp_shaders.h'], + command : [prog_vtn_bindgen2, blorp_shaders_spv, '@OUTPUT0@', '@OUTPUT1@'], +) + +idep_blorp_shaders = declare_dependency( + sources : [blorp_shaders], + include_directories : include_directories('.'), +) + files_libblorp = files( 'blorp.c', 'blorp.h', @@ -26,7 +57,10 @@ libblorp = static_library( include_directories : [inc_include, inc_src, inc_intel, inc_intel_compiler], c_args : [no_override_init_args], gnu_symbol_visibility : 'hidden', - dependencies : [idep_nir_headers, idep_genxml, idep_mesautil, idep_intel_dev], + dependencies : [ + idep_nir_headers, idep_genxml, idep_mesautil, idep_intel_dev, + idep_blorp_shaders + ], build_by_default: false, ) @@ -41,7 +75,10 @@ if with_intel_elk include_directories : [inc_include, inc_src, inc_intel], c_args : [no_override_init_args], gnu_symbol_visibility : 'hidden', - dependencies : [idep_nir_headers, idep_genxml, idep_mesautil, idep_intel_dev], + dependencies : [ + idep_nir_headers, idep_genxml, idep_mesautil, idep_intel_dev, + idep_blorp_shaders + ], build_by_default: true, # FIXME XXX )