llvmpipe/linear: convert to using nir for output.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24436>
This commit is contained in:
Dave Airlie
2023-08-03 13:00:09 +10:00
parent 8477b97f1b
commit 90c4468ed0

View File

@@ -144,14 +144,14 @@ llvm_fragment_body(struct lp_build_context *bld,
LLVMValueRef result = NULL;
bool rgba_order = (variant->key.cbuf_format[0] == PIPE_FORMAT_R8G8B8A8_UNORM ||
variant->key.cbuf_format[0] == PIPE_FORMAT_R8G8B8X8_UNORM);
struct nir_shader *nir = shader->base.ir.nir;
sampler->instance = 0;
/*
* Advance inputs
*/
unsigned i;
for (i = 0; i < shader->info.base.num_inputs; ++i) {
for (i = 0; i < util_bitcount64(nir->info.inputs_read); ++i) {
inputs[i] =
lp_build_pointer_get2(builder, bld->vec_type, inputs_ptrs[i], sampler->counter);
assert(LLVMTypeOf(inputs[i]) == bld->vec_type);
@@ -164,7 +164,7 @@ llvm_fragment_body(struct lp_build_context *bld,
outputs[i] = bld->undef;
}
nir_shader *clone = nir_shader_clone(NULL, shader->base.ir.nir);
nir_shader *clone = nir_shader_clone(NULL, nir);
lp_build_nir_aos(gallivm, clone, fs_type,
rgba_order ? rgba_swizzles : bgra_swizzles,
consts_ptr, inputs, outputs,
@@ -174,20 +174,22 @@ llvm_fragment_body(struct lp_build_context *bld,
/*
* Blend output color
*/
for (i = 0; i < shader->info.base.num_outputs; ++i) {
if (!outputs[i])
nir_foreach_shader_out_variable(var, nir) {
unsigned slots = nir_variable_count_slots(var, var->type);
for (unsigned s = 0; s < slots; s++) {
unsigned idx = var->data.driver_location + s;
if (!outputs[idx])
continue;
LLVMValueRef output = LLVMBuildLoad2(builder, bld->vec_type, outputs[i], "");
LLVMValueRef output = LLVMBuildLoad2(builder, bld->vec_type, outputs[idx], "");
lp_build_name(output, "output%u", i);
unsigned cbuf = shader->info.base.output_semantic_index[i];
unsigned cbuf = var->data.location - FRAG_RESULT_DATA0 + s;
lp_build_name(output, "cbuf%u", cbuf);
if (shader->info.base.output_semantic_name[i]
!= TGSI_SEMANTIC_COLOR || cbuf != 0) {
if (var->data.location < FRAG_RESULT_DATA0 || s > 0)
continue;
}
/* Perform alpha test if necessary */
LLVMValueRef mask = NULL;
@@ -208,7 +210,7 @@ llvm_fragment_body(struct lp_build_context *bld,
result = lp_build_blend_aos(gallivm,
&variant->key.blend,
variant->key.cbuf_format[i],
variant->key.cbuf_format[idx],
fs_type,
cbuf, /* rt */
output, /* src */
@@ -222,6 +224,7 @@ llvm_fragment_body(struct lp_build_context *bld,
rgba_order ? rgba_swizzles : bgra_swizzles,
4);
}
}
return result;
}