llvmpipe: Improve PIPE_QUERY_PIPELINE_STATISTICS accuracy

arb_pipeline_statistics_query-frag expects the reported value to be
reasonably accurate (no 100% error).

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28227>
This commit is contained in:
Konstantin Seurer
2024-02-10 15:34:12 +01:00
parent e7ee69b24d
commit a6930640a9
4 changed files with 14 additions and 30 deletions

View File

@@ -52,7 +52,6 @@ spec@!opengl 2.0@vertex-program-two-side enabled back back2@vs and fs,Fail
spec@!opengl 3.0@clearbuffer-depth-cs-probe,Fail
spec@!opengl 3.2@layered-rendering@clear-color-mismatched-layer-count,Fail
spec@arb_enhanced_layouts@execution@component-layout@vs-fs-array-dvec3,Fail
spec@arb_pipeline_statistics_query@arb_pipeline_statistics_query-frag,Fail
spec@arb_post_depth_coverage@arb_post_depth_coverage-multisampling,Fail
spec@arb_program_interface_query@arb_program_interface_query-getprogramresourceindex,Fail

View File

@@ -200,12 +200,7 @@ llvmpipe_get_query_result(struct pipe_context *pipe,
for (unsigned i = 0; i < num_threads; i++) {
sum += pq->end[i];
}
/* The FS/PS operates on a block of pixels at a time. The counter is
* incremented per block so we multiply by pixels per block here.
* This will not be a pixel-exact result.
*/
pq->stats.ps_invocations =
sum * LP_RASTER_BLOCK_SIZE * LP_RASTER_BLOCK_SIZE;
pq->stats.ps_invocations = sum;
result->pipeline_statistics = pq->stats;
}
break;
@@ -334,7 +329,6 @@ llvmpipe_get_query_result_resource(struct pipe_context *pipe,
for (unsigned i = 0; i < num_threads; i++) {
value += pq->end[i];
}
value *= LP_RASTER_BLOCK_SIZE * LP_RASTER_BLOCK_SIZE;
break;
case PIPE_STAT_QUERY_HS_INVOCATIONS:
value = pq->stats.hs_invocations;

View File

@@ -1067,6 +1067,19 @@ generate_fs_loop(struct gallivm_state *gallivm,
/* Build the actual shader */
lp_build_nir_soa(gallivm, nir, &params, outputs);
/*
* Must not count ps invocations if there's a null shader.
* (It would be ok to count with null shader if there's d/s tests,
* but only if there's d/s buffers too, which is different
* to implicit rasterization disable which must not depend
* on the d/s buffers.)
* Could disable if there's no stats query, but maybe not worth it.
*/
if (shader->info.base.num_instructions > 1) {
LLVMValueRef invocs = lp_jit_thread_data_ps_invocations(gallivm, thread_data_type, thread_data_ptr);
lp_build_occlusion_count(gallivm, type, lp_build_mask_value(&mask), invocs);
}
/* Alpha test */
if (key->alpha.enabled) {
int color0 = find_output_by_frag_result(nir, FRAG_RESULT_DATA0);
@@ -3264,27 +3277,6 @@ generate_fragment(struct llvmpipe_context *lp,
assert(builder);
LLVMPositionBuilderAtEnd(builder, block);
/*
* Must not count ps invocations if there's a null shader.
* (It would be ok to count with null shader if there's d/s tests,
* but only if there's d/s buffers too, which is different
* to implicit rasterization disable which must not depend
* on the d/s buffers.)
* Could use popcount on mask, but pixel accuracy is not required.
* Could disable if there's no stats query, but maybe not worth it.
*/
if (shader->info.base.num_instructions > 1) {
LLVMValueRef invocs, val;
LLVMTypeRef invocs_type = LLVMInt64TypeInContext(gallivm->context);
invocs = lp_jit_thread_data_ps_invocations(gallivm, variant->jit_thread_data_type, thread_data_ptr);
val = LLVMBuildLoad2(builder, invocs_type, invocs, "");
val = LLVMBuildAdd(builder, val,
LLVMConstInt(LLVMInt64TypeInContext(gallivm->context),
1, 0),
"invoc_count");
LLVMBuildStore(builder, val, invocs);
}
/* code generated texture sampling */
struct lp_build_sampler_soa *sampler =
lp_llvm_sampler_soa_create(lp_fs_variant_key_samplers(key),

View File

@@ -46,7 +46,6 @@ spec@!opengl 2.1@pbo,Fail
spec@!opengl 2.1@pbo@test_polygon_stip,Fail
spec@!opengl 2.1@polygon-stipple-fs,Fail
spec@arb_gpu_shader_fp64@execution@arb_gpu_shader_fp64-tf-separate,Fail
spec@arb_pipeline_statistics_query@arb_pipeline_statistics_query-frag,Fail
spec@arb_point_sprite@arb_point_sprite-mipmap,Fail
spec@arb_program_interface_query@arb_program_interface_query-getprogramresourceindex,Fail
spec@arb_program_interface_query@arb_program_interface_query-getprogramresourceindex@'vs_input2[1][0]' on GL_PROGRAM_INPUT,Fail