gallium/u_tests: add texture_barrier and FBFETCH tests
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
This commit is contained in:
parent
022c5b22fe
commit
125c0529f3
|
@ -228,7 +228,7 @@ util_probe_rect_rgba_multi(struct pipe_context *ctx, struct pipe_resource *tex,
|
|||
expected[e*4], expected[e*4+1],
|
||||
expected[e*4+2], expected[e*4+3]);
|
||||
printf("Got: %.3f, %.3f, %.3f, %.3f\n",
|
||||
probe[0], probe[1], probe[2], probe[2]);
|
||||
probe[0], probe[1], probe[2], probe[3]);
|
||||
pass = false;
|
||||
goto done;
|
||||
}
|
||||
|
@ -592,6 +592,113 @@ test_sync_file_fences(struct pipe_context *ctx)
|
|||
util_report_result(pass);
|
||||
}
|
||||
|
||||
static void
|
||||
test_texture_barrier(struct pipe_context *ctx, bool use_fbfetch)
|
||||
{
|
||||
struct cso_context *cso;
|
||||
struct pipe_resource *cb;
|
||||
void *fs, *vs;
|
||||
struct pipe_sampler_view *view = NULL;
|
||||
const char *text;
|
||||
|
||||
if (!ctx->screen->get_param(ctx->screen, PIPE_CAP_TEXTURE_BARRIER)) {
|
||||
util_report_result_helper(SKIP, "%s: %s", __func__,
|
||||
use_fbfetch ? "FBFETCH" : "sampler");
|
||||
return;
|
||||
}
|
||||
if (use_fbfetch &&
|
||||
!ctx->screen->get_param(ctx->screen, PIPE_CAP_TGSI_FS_FBFETCH)) {
|
||||
util_report_result_helper(SKIP, "%s: %s", __func__,
|
||||
use_fbfetch ? "FBFETCH" : "sampler");
|
||||
return;
|
||||
}
|
||||
|
||||
cso = cso_create_context(ctx, 0);
|
||||
cb = util_create_texture2d(ctx->screen, 256, 256,
|
||||
PIPE_FORMAT_R8G8B8A8_UNORM);
|
||||
util_set_common_states_and_clear(cso, ctx, cb);
|
||||
|
||||
if (use_fbfetch) {
|
||||
/* Fragment shader. */
|
||||
text = "FRAG\n"
|
||||
"DCL OUT[0], COLOR[0]\n"
|
||||
"DCL TEMP[0]\n"
|
||||
"IMM[0] FLT32 { 0.1, 0.2, 0.3, 0.4}\n"
|
||||
|
||||
"FBFETCH TEMP[0], OUT[0]\n"
|
||||
"ADD OUT[0], TEMP[0], IMM[0]\n"
|
||||
"END\n";
|
||||
} else {
|
||||
struct pipe_sampler_view templ = {{0}};
|
||||
templ.format = cb->format;
|
||||
templ.target = cb->target;
|
||||
templ.swizzle_r = PIPE_SWIZZLE_X;
|
||||
templ.swizzle_g = PIPE_SWIZZLE_Y;
|
||||
templ.swizzle_b = PIPE_SWIZZLE_Z;
|
||||
templ.swizzle_a = PIPE_SWIZZLE_W;
|
||||
view = ctx->create_sampler_view(ctx, cb, &templ);
|
||||
ctx->set_sampler_views(ctx, PIPE_SHADER_FRAGMENT, 0, 1, &view);
|
||||
|
||||
/* Fragment shader. */
|
||||
text = "FRAG\n"
|
||||
"DCL SV[0], POSITION\n"
|
||||
"DCL SAMP[0]\n"
|
||||
"DCL SVIEW[0], 2D, FLOAT\n"
|
||||
"DCL OUT[0], COLOR[0]\n"
|
||||
"DCL TEMP[0]\n"
|
||||
"IMM[0] FLT32 { 0.1, 0.2, 0.3, 0.4}\n"
|
||||
"IMM[1] INT32 { 0, 0, 0, 0}\n"
|
||||
|
||||
"F2I TEMP[0].xy, SV[0].xyyy\n"
|
||||
"MOV TEMP[0].z, IMM[1].xxxx\n"
|
||||
"TXF TEMP[0], TEMP[0].xyzz, SAMP[0], 2D\n"
|
||||
"ADD OUT[0], TEMP[0], IMM[0]\n"
|
||||
"END\n";
|
||||
}
|
||||
|
||||
struct tgsi_token tokens[1000];
|
||||
struct pipe_shader_state state;
|
||||
|
||||
if (!tgsi_text_translate(text, tokens, ARRAY_SIZE(tokens))) {
|
||||
assert(0);
|
||||
util_report_result_helper(FAIL, "%s: %s", __func__,
|
||||
use_fbfetch ? "FBFETCH" : "sampler");
|
||||
return;
|
||||
}
|
||||
pipe_shader_state_from_tgsi(&state, tokens);
|
||||
#if 0
|
||||
tgsi_dump(state.tokens, 0);
|
||||
#endif
|
||||
|
||||
fs = ctx->create_fs_state(ctx, &state);
|
||||
cso_set_fragment_shader_handle(cso, fs);
|
||||
|
||||
/* Vertex shader. */
|
||||
vs = util_set_passthrough_vertex_shader(cso, ctx, false);
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
ctx->texture_barrier(ctx,
|
||||
use_fbfetch ? PIPE_TEXTURE_BARRIER_FRAMEBUFFER :
|
||||
PIPE_TEXTURE_BARRIER_SAMPLER);
|
||||
util_draw_fullscreen_quad(cso);
|
||||
}
|
||||
|
||||
/* Probe pixels. */
|
||||
static const float expected[] = {0.3, 0.5, 0.7, 0.9};
|
||||
bool pass = util_probe_rect_rgba(ctx, cb, 0, 0,
|
||||
cb->width0, cb->height0, expected);
|
||||
|
||||
/* Cleanup. */
|
||||
cso_destroy_context(cso);
|
||||
ctx->delete_vs_state(ctx, vs);
|
||||
ctx->delete_fs_state(ctx, fs);
|
||||
pipe_sampler_view_reference(&view, NULL);
|
||||
pipe_resource_reference(&cb, NULL);
|
||||
|
||||
util_report_result_helper(pass, "%s: %s", __func__,
|
||||
use_fbfetch ? "FBFETCH" : "sampler");
|
||||
}
|
||||
|
||||
/**
|
||||
* Run all tests. This should be run with a clean context after
|
||||
* context_create.
|
||||
|
@ -607,6 +714,8 @@ util_run_tests(struct pipe_screen *screen)
|
|||
null_sampler_view(ctx, TGSI_TEXTURE_BUFFER);
|
||||
util_test_constant_buffer(ctx, NULL);
|
||||
test_sync_file_fences(ctx);
|
||||
test_texture_barrier(ctx, false);
|
||||
test_texture_barrier(ctx, true);
|
||||
|
||||
ctx->destroy(ctx);
|
||||
|
||||
|
|
Loading…
Reference in New Issue