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