gallium: delete tests
we have CI now Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> H*ck-yes-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34048>
This commit is contained in:

committed by
Marge Bot

parent
186fb5e73a
commit
185a3f9105
@@ -256,9 +256,6 @@ if with_platform_windows
|
||||
subdir('targets/libgl-gdi')
|
||||
endif
|
||||
endif
|
||||
if with_tests
|
||||
subdir('tests')
|
||||
endif
|
||||
if with_swrast_vk
|
||||
subdir('frontends/lavapipe')
|
||||
subdir('targets/lavapipe')
|
||||
|
@@ -1,10 +0,0 @@
|
||||
# Copyright © 2018 Intel Corporation
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
if not with_platform_windows
|
||||
# pipe-loader doesn't build on windows.
|
||||
subdir('trivial')
|
||||
endif
|
||||
if with_gallium_swrast
|
||||
subdir('unit')
|
||||
endif
|
@@ -1,12 +0,0 @@
|
||||
FRAG
|
||||
|
||||
DCL IN[0], COLOR, LINEAR
|
||||
DCL OUT[0], COLOR
|
||||
|
||||
IMM FLT32 { 1, 0, 0, 1 }
|
||||
IMM FLT32 { 0, 1, 1, 0 }
|
||||
IMM FLT32 { 1, 0,-1, 0 }
|
||||
|
||||
CMP OUT[0], IMM[2], IMM[0], IMM[1]
|
||||
|
||||
END
|
@@ -1,13 +0,0 @@
|
||||
# Copyright © 2018 Intel Corporation
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
foreach t : ['tri', 'quad-tex']
|
||||
executable(
|
||||
t,
|
||||
'@0@.c'.format(t),
|
||||
include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
|
||||
link_with : [libgallium, libpipe_loader_dynamic],
|
||||
dependencies : idep_mesautil,
|
||||
install : false,
|
||||
)
|
||||
endforeach
|
@@ -1,359 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright © 2010 Jakob Bornecrantz
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
#define USE_TRACE 0
|
||||
#define WIDTH 300
|
||||
#define HEIGHT 300
|
||||
#define NEAR 0
|
||||
#define FAR 1
|
||||
#define FLIP 0
|
||||
|
||||
/* pipe_*_state structs */
|
||||
#include "pipe/p_state.h"
|
||||
/* pipe_context */
|
||||
#include "pipe/p_context.h"
|
||||
/* pipe_screen */
|
||||
#include "pipe/p_screen.h"
|
||||
/* PIPE_* */
|
||||
#include "pipe/p_defines.h"
|
||||
/* TGSI_SEMANTIC_{POSITION|GENERIC} */
|
||||
#include "pipe/p_shader_tokens.h"
|
||||
/* pipe_buffer_* helpers */
|
||||
#include "util/u_inlines.h"
|
||||
|
||||
/* constant state object helper */
|
||||
#include "cso_cache/cso_context.h"
|
||||
|
||||
#include "util/macros.h"
|
||||
/* u_sampler_view_default_template */
|
||||
#include "util/u_sampler.h"
|
||||
/* debug_dump_surface_bmp */
|
||||
#include "util/u_debug_image.h"
|
||||
/* util_draw_vertex_buffer helper */
|
||||
#include "util/u_draw_quad.h"
|
||||
/* FREE & CALLOC_STRUCT */
|
||||
#include "util/u_memory.h"
|
||||
/* util_make_[fragment|vertex]_passthrough_shader */
|
||||
#include "util/u_simple_shaders.h"
|
||||
/* to get a hardware pipe driver */
|
||||
#include "pipe-loader/pipe_loader.h"
|
||||
|
||||
struct program
|
||||
{
|
||||
struct pipe_loader_device *dev;
|
||||
struct pipe_screen *screen;
|
||||
struct pipe_context *pipe;
|
||||
struct cso_context *cso;
|
||||
|
||||
struct pipe_blend_state blend;
|
||||
struct pipe_depth_stencil_alpha_state depthstencil;
|
||||
struct pipe_rasterizer_state rasterizer;
|
||||
struct pipe_sampler_state sampler;
|
||||
struct pipe_viewport_state viewport;
|
||||
struct pipe_framebuffer_state framebuffer;
|
||||
struct cso_velems_state velem;
|
||||
|
||||
void *vs;
|
||||
void *fs;
|
||||
|
||||
union pipe_color_union clear_color;
|
||||
|
||||
struct pipe_resource *vbuf;
|
||||
struct pipe_resource *target;
|
||||
struct pipe_resource *tex;
|
||||
struct pipe_sampler_view *view;
|
||||
};
|
||||
|
||||
static void init_prog(struct program *p)
|
||||
{
|
||||
struct pipe_surface surf_tmpl;
|
||||
ASSERTED int ret;
|
||||
|
||||
/* find a hardware device */
|
||||
ret = pipe_loader_probe(&p->dev, 1, false);
|
||||
assert(ret);
|
||||
|
||||
/* init a pipe screen */
|
||||
p->screen = pipe_loader_create_screen(p->dev, false);
|
||||
assert(p->screen);
|
||||
|
||||
/* create the pipe driver context and cso context */
|
||||
p->pipe = p->screen->context_create(p->screen, NULL, 0);
|
||||
p->cso = cso_create_context(p->pipe, 0);
|
||||
|
||||
/* set clear color */
|
||||
p->clear_color.f[0] = 0.3;
|
||||
p->clear_color.f[1] = 0.1;
|
||||
p->clear_color.f[2] = 0.3;
|
||||
p->clear_color.f[3] = 1.0;
|
||||
|
||||
/* vertex buffer */
|
||||
{
|
||||
float vertices[4][2][4] = {
|
||||
{
|
||||
{ 0.9f, 0.9f, 0.0f, 1.0f },
|
||||
{ 1.0f, 1.0f, 0.0f, 1.0f }
|
||||
},
|
||||
{
|
||||
{ -0.9f, 0.9f, 0.0f, 1.0f },
|
||||
{ 0.0f, 1.0f, 0.0f, 1.0f }
|
||||
},
|
||||
{
|
||||
{ -0.9f, -0.9f, 0.0f, 1.0f },
|
||||
{ 0.0f, 0.0f, 1.0f, 1.0f }
|
||||
},
|
||||
{
|
||||
{ 0.9f, -0.9f, 0.0f, 1.0f },
|
||||
{ 1.0f, 0.0f, 1.0f, 1.0f }
|
||||
}
|
||||
};
|
||||
|
||||
p->vbuf = pipe_buffer_create(p->screen, PIPE_BIND_VERTEX_BUFFER,
|
||||
PIPE_USAGE_DEFAULT, sizeof(vertices));
|
||||
pipe_buffer_write(p->pipe, p->vbuf, 0, sizeof(vertices), vertices);
|
||||
}
|
||||
|
||||
/* render target texture */
|
||||
{
|
||||
struct pipe_resource tmplt;
|
||||
memset(&tmplt, 0, sizeof(tmplt));
|
||||
tmplt.target = PIPE_TEXTURE_2D;
|
||||
tmplt.format = PIPE_FORMAT_B8G8R8A8_UNORM; /* All drivers support this */
|
||||
tmplt.width0 = WIDTH;
|
||||
tmplt.height0 = HEIGHT;
|
||||
tmplt.depth0 = 1;
|
||||
tmplt.array_size = 1;
|
||||
tmplt.last_level = 0;
|
||||
tmplt.bind = PIPE_BIND_RENDER_TARGET;
|
||||
|
||||
p->target = p->screen->resource_create(p->screen, &tmplt);
|
||||
}
|
||||
|
||||
/* sampler texture */
|
||||
{
|
||||
uint32_t *ptr;
|
||||
struct pipe_transfer *t;
|
||||
struct pipe_resource t_tmplt;
|
||||
struct pipe_sampler_view v_tmplt;
|
||||
struct pipe_box box;
|
||||
|
||||
memset(&t_tmplt, 0, sizeof(t_tmplt));
|
||||
t_tmplt.target = PIPE_TEXTURE_2D;
|
||||
t_tmplt.format = PIPE_FORMAT_B8G8R8A8_UNORM; /* All drivers support this */
|
||||
t_tmplt.width0 = 2;
|
||||
t_tmplt.height0 = 2;
|
||||
t_tmplt.depth0 = 1;
|
||||
t_tmplt.array_size = 1;
|
||||
t_tmplt.last_level = 0;
|
||||
t_tmplt.bind = PIPE_BIND_RENDER_TARGET;
|
||||
|
||||
p->tex = p->screen->resource_create(p->screen, &t_tmplt);
|
||||
|
||||
memset(&box, 0, sizeof(box));
|
||||
box.width = 2;
|
||||
box.height = 2;
|
||||
box.depth = 1;
|
||||
|
||||
ptr = p->pipe->texture_map(p->pipe, p->tex, 0, PIPE_MAP_WRITE, &box, &t);
|
||||
ptr[0] = 0xffff0000;
|
||||
ptr[1] = 0xff0000ff;
|
||||
ptr[2] = 0xff00ff00;
|
||||
ptr[3] = 0xffffff00;
|
||||
p->pipe->texture_unmap(p->pipe, t);
|
||||
|
||||
u_sampler_view_default_template(&v_tmplt, p->tex, p->tex->format);
|
||||
|
||||
p->view = p->pipe->create_sampler_view(p->pipe, p->tex, &v_tmplt);
|
||||
}
|
||||
|
||||
/* disabled blending/masking */
|
||||
memset(&p->blend, 0, sizeof(p->blend));
|
||||
p->blend.rt[0].colormask = PIPE_MASK_RGBA;
|
||||
|
||||
/* no-op depth/stencil/alpha */
|
||||
memset(&p->depthstencil, 0, sizeof(p->depthstencil));
|
||||
|
||||
/* rasterizer */
|
||||
memset(&p->rasterizer, 0, sizeof(p->rasterizer));
|
||||
p->rasterizer.cull_face = PIPE_FACE_NONE;
|
||||
p->rasterizer.half_pixel_center = 1;
|
||||
p->rasterizer.bottom_edge_rule = 1;
|
||||
p->rasterizer.depth_clip_near = 1;
|
||||
p->rasterizer.depth_clip_far = 1;
|
||||
|
||||
/* sampler */
|
||||
memset(&p->sampler, 0, sizeof(p->sampler));
|
||||
p->sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
|
||||
p->sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
|
||||
p->sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
|
||||
p->sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
|
||||
p->sampler.min_img_filter = PIPE_TEX_MIPFILTER_LINEAR;
|
||||
p->sampler.mag_img_filter = PIPE_TEX_MIPFILTER_LINEAR;
|
||||
|
||||
surf_tmpl.format = PIPE_FORMAT_B8G8R8A8_UNORM; /* All drivers support this */
|
||||
surf_tmpl.u.tex.level = 0;
|
||||
surf_tmpl.u.tex.first_layer = 0;
|
||||
surf_tmpl.u.tex.last_layer = 0;
|
||||
/* drawing destination */
|
||||
memset(&p->framebuffer, 0, sizeof(p->framebuffer));
|
||||
p->framebuffer.width = WIDTH;
|
||||
p->framebuffer.height = HEIGHT;
|
||||
p->framebuffer.nr_cbufs = 1;
|
||||
p->framebuffer.cbufs[0] = p->pipe->create_surface(p->pipe, p->target, &surf_tmpl);
|
||||
|
||||
/* viewport, depth isn't really needed */
|
||||
{
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
float z = NEAR;
|
||||
float half_width = (float)WIDTH / 2.0f;
|
||||
float half_height = (float)HEIGHT / 2.0f;
|
||||
float half_depth = ((float)FAR - (float)NEAR) / 2.0f;
|
||||
float scale, bias;
|
||||
|
||||
if (FLIP) {
|
||||
scale = -1.0f;
|
||||
bias = (float)HEIGHT;
|
||||
} else {
|
||||
scale = 1.0f;
|
||||
bias = 0.0f;
|
||||
}
|
||||
|
||||
p->viewport.scale[0] = half_width;
|
||||
p->viewport.scale[1] = half_height * scale;
|
||||
p->viewport.scale[2] = half_depth;
|
||||
|
||||
p->viewport.translate[0] = half_width + x;
|
||||
p->viewport.translate[1] = (half_height + y) * scale + bias;
|
||||
p->viewport.translate[2] = half_depth + z;
|
||||
|
||||
p->viewport.swizzle_x = PIPE_VIEWPORT_SWIZZLE_POSITIVE_X;
|
||||
p->viewport.swizzle_y = PIPE_VIEWPORT_SWIZZLE_POSITIVE_Y;
|
||||
p->viewport.swizzle_z = PIPE_VIEWPORT_SWIZZLE_POSITIVE_Z;
|
||||
p->viewport.swizzle_w = PIPE_VIEWPORT_SWIZZLE_POSITIVE_W;
|
||||
}
|
||||
|
||||
/* vertex elements state */
|
||||
memset(&p->velem, 0, sizeof(p->velem));
|
||||
p->velem.count = 2;
|
||||
|
||||
p->velem.velems[0].src_offset = 0 * 4 * sizeof(float); /* offset 0, first element */
|
||||
p->velem.velems[0].instance_divisor = 0;
|
||||
p->velem.velems[0].vertex_buffer_index = 0;
|
||||
p->velem.velems[0].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
|
||||
p->velem.velems[0].src_stride = 2 * 4 * sizeof(float);
|
||||
|
||||
p->velem.velems[1].src_offset = 1 * 4 * sizeof(float); /* offset 16, second element */
|
||||
p->velem.velems[1].instance_divisor = 0;
|
||||
p->velem.velems[1].vertex_buffer_index = 0;
|
||||
p->velem.velems[1].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
|
||||
p->velem.velems[1].src_stride = 2 * 4 * sizeof(float);
|
||||
|
||||
/* vertex shader */
|
||||
{
|
||||
const enum tgsi_semantic semantic_names[] =
|
||||
{ TGSI_SEMANTIC_POSITION, TGSI_SEMANTIC_GENERIC };
|
||||
const uint semantic_indexes[] = { 0, 0 };
|
||||
p->vs = util_make_vertex_passthrough_shader(p->pipe, 2, semantic_names, semantic_indexes, false);
|
||||
}
|
||||
|
||||
/* fragment shader */
|
||||
p->fs = util_make_fragment_tex_shader(p->pipe, TGSI_TEXTURE_2D,
|
||||
TGSI_RETURN_TYPE_FLOAT,
|
||||
TGSI_RETURN_TYPE_FLOAT, false,
|
||||
false);
|
||||
}
|
||||
|
||||
static void close_prog(struct program *p)
|
||||
{
|
||||
cso_destroy_context(p->cso);
|
||||
|
||||
p->pipe->delete_vs_state(p->pipe, p->vs);
|
||||
p->pipe->delete_fs_state(p->pipe, p->fs);
|
||||
|
||||
pipe_surface_reference(&p->framebuffer.cbufs[0], NULL);
|
||||
pipe_sampler_view_reference(&p->view, NULL);
|
||||
pipe_resource_reference(&p->target, NULL);
|
||||
pipe_resource_reference(&p->tex, NULL);
|
||||
pipe_resource_reference(&p->vbuf, NULL);
|
||||
|
||||
p->pipe->destroy(p->pipe);
|
||||
p->screen->destroy(p->screen);
|
||||
pipe_loader_release(&p->dev, 1);
|
||||
|
||||
FREE(p);
|
||||
}
|
||||
|
||||
static void draw(struct program *p)
|
||||
{
|
||||
const struct pipe_sampler_state *samplers[] = {&p->sampler};
|
||||
|
||||
/* set the render target */
|
||||
cso_set_framebuffer(p->cso, &p->framebuffer);
|
||||
|
||||
/* clear the render target */
|
||||
p->pipe->clear(p->pipe, PIPE_CLEAR_COLOR, NULL, &p->clear_color, 0, 0);
|
||||
|
||||
/* set misc state we care about */
|
||||
cso_set_blend(p->cso, &p->blend);
|
||||
cso_set_depth_stencil_alpha(p->cso, &p->depthstencil);
|
||||
cso_set_rasterizer(p->cso, &p->rasterizer);
|
||||
cso_set_viewport(p->cso, &p->viewport);
|
||||
|
||||
/* sampler */
|
||||
cso_set_samplers(p->cso, PIPE_SHADER_FRAGMENT, 1, samplers);
|
||||
|
||||
/* texture sampler view */
|
||||
p->pipe->set_sampler_views(p->pipe, PIPE_SHADER_FRAGMENT, 0, 1, 0, &p->view);
|
||||
|
||||
/* shaders */
|
||||
cso_set_fragment_shader_handle(p->cso, p->fs);
|
||||
cso_set_vertex_shader_handle(p->cso, p->vs);
|
||||
|
||||
/* vertex element data */
|
||||
cso_set_vertex_elements(p->cso, &p->velem);
|
||||
|
||||
util_draw_vertex_buffer(p->pipe, p->cso,
|
||||
p->vbuf, 0, false,
|
||||
MESA_PRIM_QUADS,
|
||||
4, /* verts */
|
||||
2); /* attribs/vert */
|
||||
|
||||
p->pipe->flush(p->pipe, NULL, 0);
|
||||
|
||||
debug_dump_surface_bmp(p->pipe, "result.bmp", p->framebuffer.cbufs[0]);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
struct program *p = CALLOC_STRUCT(program);
|
||||
|
||||
init_prog(p);
|
||||
draw(p);
|
||||
close_prog(p);
|
||||
|
||||
return 0;
|
||||
}
|
@@ -1,291 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright © 2010 Jakob Bornecrantz
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
#define USE_TRACE 0
|
||||
#define WIDTH 300
|
||||
#define HEIGHT 300
|
||||
#define NEAR 0
|
||||
#define FAR 1
|
||||
#define FLIP 0
|
||||
|
||||
/* pipe_*_state structs */
|
||||
#include "pipe/p_state.h"
|
||||
/* pipe_context */
|
||||
#include "pipe/p_context.h"
|
||||
/* pipe_screen */
|
||||
#include "pipe/p_screen.h"
|
||||
/* PIPE_* */
|
||||
#include "pipe/p_defines.h"
|
||||
/* TGSI_SEMANTIC_{POSITION|GENERIC} */
|
||||
#include "pipe/p_shader_tokens.h"
|
||||
/* pipe_buffer_* helpers */
|
||||
#include "util/u_inlines.h"
|
||||
|
||||
/* constant state object helper */
|
||||
#include "cso_cache/cso_context.h"
|
||||
|
||||
/* debug_dump_surface_bmp */
|
||||
#include "util/u_debug_image.h"
|
||||
/* util_draw_vertex_buffer helper */
|
||||
#include "util/u_draw_quad.h"
|
||||
/* FREE & CALLOC_STRUCT */
|
||||
#include "util/u_memory.h"
|
||||
/* util_make_[fragment|vertex]_passthrough_shader */
|
||||
#include "util/u_simple_shaders.h"
|
||||
/* to get a hardware pipe driver */
|
||||
#include "pipe-loader/pipe_loader.h"
|
||||
|
||||
struct program
|
||||
{
|
||||
struct pipe_loader_device *dev;
|
||||
struct pipe_screen *screen;
|
||||
struct pipe_context *pipe;
|
||||
struct cso_context *cso;
|
||||
|
||||
struct pipe_blend_state blend;
|
||||
struct pipe_depth_stencil_alpha_state depthstencil;
|
||||
struct pipe_rasterizer_state rasterizer;
|
||||
struct pipe_viewport_state viewport;
|
||||
struct pipe_framebuffer_state framebuffer;
|
||||
struct cso_velems_state velem;
|
||||
|
||||
void *vs;
|
||||
void *fs;
|
||||
|
||||
union pipe_color_union clear_color;
|
||||
|
||||
struct pipe_resource *vbuf;
|
||||
struct pipe_resource *target;
|
||||
};
|
||||
|
||||
static void init_prog(struct program *p)
|
||||
{
|
||||
struct pipe_surface surf_tmpl;
|
||||
ASSERTED int ret;
|
||||
|
||||
/* find a hardware device */
|
||||
ret = pipe_loader_probe(&p->dev, 1, false);
|
||||
assert(ret);
|
||||
|
||||
/* init a pipe screen */
|
||||
p->screen = pipe_loader_create_screen(p->dev, false);
|
||||
assert(p->screen);
|
||||
|
||||
/* create the pipe driver context and cso context */
|
||||
p->pipe = p->screen->context_create(p->screen, NULL, 0);
|
||||
p->cso = cso_create_context(p->pipe, 0);
|
||||
|
||||
/* set clear color */
|
||||
p->clear_color.f[0] = 0.3;
|
||||
p->clear_color.f[1] = 0.1;
|
||||
p->clear_color.f[2] = 0.3;
|
||||
p->clear_color.f[3] = 1.0;
|
||||
|
||||
/* vertex buffer */
|
||||
{
|
||||
float vertices[4][2][4] = {
|
||||
{
|
||||
{ 0.0f, -0.9f, 0.0f, 1.0f },
|
||||
{ 1.0f, 0.0f, 0.0f, 1.0f }
|
||||
},
|
||||
{
|
||||
{ -0.9f, 0.9f, 0.0f, 1.0f },
|
||||
{ 0.0f, 1.0f, 0.0f, 1.0f }
|
||||
},
|
||||
{
|
||||
{ 0.9f, 0.9f, 0.0f, 1.0f },
|
||||
{ 0.0f, 0.0f, 1.0f, 1.0f }
|
||||
}
|
||||
};
|
||||
|
||||
p->vbuf = pipe_buffer_create(p->screen, PIPE_BIND_VERTEX_BUFFER,
|
||||
PIPE_USAGE_DEFAULT, sizeof(vertices));
|
||||
pipe_buffer_write(p->pipe, p->vbuf, 0, sizeof(vertices), vertices);
|
||||
}
|
||||
|
||||
/* render target texture */
|
||||
{
|
||||
struct pipe_resource tmplt;
|
||||
memset(&tmplt, 0, sizeof(tmplt));
|
||||
tmplt.target = PIPE_TEXTURE_2D;
|
||||
tmplt.format = PIPE_FORMAT_B8G8R8A8_UNORM; /* All drivers support this */
|
||||
tmplt.width0 = WIDTH;
|
||||
tmplt.height0 = HEIGHT;
|
||||
tmplt.depth0 = 1;
|
||||
tmplt.array_size = 1;
|
||||
tmplt.last_level = 0;
|
||||
tmplt.bind = PIPE_BIND_RENDER_TARGET;
|
||||
|
||||
p->target = p->screen->resource_create(p->screen, &tmplt);
|
||||
}
|
||||
|
||||
/* disabled blending/masking */
|
||||
memset(&p->blend, 0, sizeof(p->blend));
|
||||
p->blend.rt[0].colormask = PIPE_MASK_RGBA;
|
||||
|
||||
/* no-op depth/stencil/alpha */
|
||||
memset(&p->depthstencil, 0, sizeof(p->depthstencil));
|
||||
|
||||
/* rasterizer */
|
||||
memset(&p->rasterizer, 0, sizeof(p->rasterizer));
|
||||
p->rasterizer.cull_face = PIPE_FACE_NONE;
|
||||
p->rasterizer.half_pixel_center = 1;
|
||||
p->rasterizer.bottom_edge_rule = 1;
|
||||
p->rasterizer.depth_clip_near = 1;
|
||||
p->rasterizer.depth_clip_far = 1;
|
||||
|
||||
surf_tmpl.format = PIPE_FORMAT_B8G8R8A8_UNORM;
|
||||
surf_tmpl.u.tex.level = 0;
|
||||
surf_tmpl.u.tex.first_layer = 0;
|
||||
surf_tmpl.u.tex.last_layer = 0;
|
||||
/* drawing destination */
|
||||
memset(&p->framebuffer, 0, sizeof(p->framebuffer));
|
||||
p->framebuffer.width = WIDTH;
|
||||
p->framebuffer.height = HEIGHT;
|
||||
p->framebuffer.nr_cbufs = 1;
|
||||
p->framebuffer.cbufs[0] = p->pipe->create_surface(p->pipe, p->target, &surf_tmpl);
|
||||
|
||||
/* viewport, depth isn't really needed */
|
||||
{
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
float z = NEAR;
|
||||
float half_width = (float)WIDTH / 2.0f;
|
||||
float half_height = (float)HEIGHT / 2.0f;
|
||||
float half_depth = ((float)FAR - (float)NEAR) / 2.0f;
|
||||
float scale, bias;
|
||||
|
||||
if (FLIP) {
|
||||
scale = -1.0f;
|
||||
bias = (float)HEIGHT;
|
||||
} else {
|
||||
scale = 1.0f;
|
||||
bias = 0.0f;
|
||||
}
|
||||
|
||||
p->viewport.scale[0] = half_width;
|
||||
p->viewport.scale[1] = half_height * scale;
|
||||
p->viewport.scale[2] = half_depth;
|
||||
|
||||
p->viewport.translate[0] = half_width + x;
|
||||
p->viewport.translate[1] = (half_height + y) * scale + bias;
|
||||
p->viewport.translate[2] = half_depth + z;
|
||||
|
||||
p->viewport.swizzle_x = PIPE_VIEWPORT_SWIZZLE_POSITIVE_X;
|
||||
p->viewport.swizzle_y = PIPE_VIEWPORT_SWIZZLE_POSITIVE_Y;
|
||||
p->viewport.swizzle_z = PIPE_VIEWPORT_SWIZZLE_POSITIVE_Z;
|
||||
p->viewport.swizzle_w = PIPE_VIEWPORT_SWIZZLE_POSITIVE_W;
|
||||
}
|
||||
|
||||
/* vertex elements state */
|
||||
memset(&p->velem, 0, sizeof(p->velem));
|
||||
p->velem.count = 2;
|
||||
|
||||
p->velem.velems[0].src_offset = 0 * 4 * sizeof(float); /* offset 0, first element */
|
||||
p->velem.velems[0].instance_divisor = 0;
|
||||
p->velem.velems[0].vertex_buffer_index = 0;
|
||||
p->velem.velems[0].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
|
||||
p->velem.velems[0].src_stride = 2 * 4 * sizeof(float);
|
||||
|
||||
p->velem.velems[1].src_offset = 1 * 4 * sizeof(float); /* offset 16, second element */
|
||||
p->velem.velems[1].instance_divisor = 0;
|
||||
p->velem.velems[1].vertex_buffer_index = 0;
|
||||
p->velem.velems[1].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
|
||||
p->velem.velems[1].src_stride = 2 * 4 * sizeof(float);
|
||||
|
||||
/* vertex shader */
|
||||
{
|
||||
const enum tgsi_semantic semantic_names[] =
|
||||
{ TGSI_SEMANTIC_POSITION, TGSI_SEMANTIC_COLOR };
|
||||
const uint semantic_indexes[] = { 0, 0 };
|
||||
p->vs = util_make_vertex_passthrough_shader(p->pipe, 2, semantic_names, semantic_indexes, false);
|
||||
}
|
||||
|
||||
/* fragment shader */
|
||||
p->fs = util_make_fragment_passthrough_shader(p->pipe,
|
||||
TGSI_SEMANTIC_COLOR, TGSI_INTERPOLATE_PERSPECTIVE, true);
|
||||
}
|
||||
|
||||
static void close_prog(struct program *p)
|
||||
{
|
||||
cso_destroy_context(p->cso);
|
||||
|
||||
p->pipe->delete_vs_state(p->pipe, p->vs);
|
||||
p->pipe->delete_fs_state(p->pipe, p->fs);
|
||||
|
||||
pipe_surface_reference(&p->framebuffer.cbufs[0], NULL);
|
||||
pipe_resource_reference(&p->target, NULL);
|
||||
pipe_resource_reference(&p->vbuf, NULL);
|
||||
|
||||
p->pipe->destroy(p->pipe);
|
||||
p->screen->destroy(p->screen);
|
||||
pipe_loader_release(&p->dev, 1);
|
||||
|
||||
FREE(p);
|
||||
}
|
||||
|
||||
static void draw(struct program *p)
|
||||
{
|
||||
/* set the render target */
|
||||
cso_set_framebuffer(p->cso, &p->framebuffer);
|
||||
|
||||
/* clear the render target */
|
||||
p->pipe->clear(p->pipe, PIPE_CLEAR_COLOR, NULL, &p->clear_color, 0, 0);
|
||||
|
||||
/* set misc state we care about */
|
||||
cso_set_blend(p->cso, &p->blend);
|
||||
cso_set_depth_stencil_alpha(p->cso, &p->depthstencil);
|
||||
cso_set_rasterizer(p->cso, &p->rasterizer);
|
||||
cso_set_viewport(p->cso, &p->viewport);
|
||||
|
||||
/* shaders */
|
||||
cso_set_fragment_shader_handle(p->cso, p->fs);
|
||||
cso_set_vertex_shader_handle(p->cso, p->vs);
|
||||
|
||||
/* vertex element data */
|
||||
cso_set_vertex_elements(p->cso, &p->velem);
|
||||
|
||||
util_draw_vertex_buffer(p->pipe, p->cso,
|
||||
p->vbuf, 0, false,
|
||||
MESA_PRIM_TRIANGLES,
|
||||
3, /* verts */
|
||||
2); /* attribs/vert */
|
||||
|
||||
p->pipe->flush(p->pipe, NULL, 0);
|
||||
|
||||
debug_dump_surface_bmp(p->pipe, "result.bmp", p->framebuffer.cbufs[0]);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
struct program *p = CALLOC_STRUCT(program);
|
||||
|
||||
init_prog(p);
|
||||
draw(p);
|
||||
close_prog(p);
|
||||
|
||||
return 0;
|
||||
}
|
@@ -1,28 +0,0 @@
|
||||
# Copyright © 2018 Intel Corporation
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
foreach t : ['pipe_barrier_test', 'u_cache_test', 'u_half_test',
|
||||
'translate_test', 'u_prim_verts_test']
|
||||
exe = executable(
|
||||
t,
|
||||
'@0@.c'.format(t),
|
||||
include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
|
||||
link_with : libgallium,
|
||||
dependencies : idep_mesautil,
|
||||
install : false,
|
||||
)
|
||||
if (t == 'translate_test') # translate_test have parameters.
|
||||
# FIXME: translate_test default|generic are failing
|
||||
# test('translate_test default', exe, args : [ 'default' ])
|
||||
# test('translate_test generic', exe, args : [ 'generic' ])
|
||||
if ['x86', 'x86_64'].contains(host_machine.cpu_family())
|
||||
foreach arg : ['x86', 'nosse', 'sse', 'sse2', 'sse3', 'sse4.1']
|
||||
test('translate_test ' + arg, exe, args : [ arg ])
|
||||
endforeach
|
||||
endif
|
||||
elif t != 'u_cache_test' # u_cache_test is slow
|
||||
test(t, exe, suite: 'gallium',
|
||||
should_fail : meson.get_external_property('xfail', '').contains(t),
|
||||
)
|
||||
endif
|
||||
endforeach
|
@@ -1,131 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2009-2010 VMware, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* 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, sub license, 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 NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
* Test case for util_barrier.
|
||||
*
|
||||
* The test succeeds if no thread exits before all the other threads reach
|
||||
* the barrier.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "util/os_time.h"
|
||||
#include "util/u_atomic.h"
|
||||
#include "util/u_thread.h"
|
||||
|
||||
|
||||
#define NUM_THREADS 10
|
||||
|
||||
static int verbosity = 0;
|
||||
|
||||
static thrd_t threads[NUM_THREADS];
|
||||
static util_barrier barrier;
|
||||
static int thread_ids[NUM_THREADS];
|
||||
|
||||
static volatile int waiting = 0;
|
||||
static volatile int proceeded = 0;
|
||||
|
||||
|
||||
#define LOG(fmt, ...) \
|
||||
if (verbosity > 0) { \
|
||||
fprintf(stdout, fmt, ##__VA_ARGS__); \
|
||||
}
|
||||
|
||||
#define CHECK(_cond) \
|
||||
if (!(_cond)) { \
|
||||
fprintf(stderr, "%s:%u: `%s` failed\n", __FILE__, __LINE__, #_cond); \
|
||||
_exit(EXIT_FAILURE); \
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
thread_function(void *thread_data)
|
||||
{
|
||||
int thread_id = *((int *) thread_data);
|
||||
|
||||
LOG("thread %d starting\n", thread_id);
|
||||
os_time_sleep(thread_id * 100 * 1000);
|
||||
LOG("thread %d before barrier\n", thread_id);
|
||||
|
||||
CHECK(p_atomic_read(&proceeded) == 0);
|
||||
p_atomic_inc(&waiting);
|
||||
|
||||
util_barrier_wait(&barrier);
|
||||
|
||||
CHECK(p_atomic_read(&waiting) == NUM_THREADS);
|
||||
|
||||
p_atomic_inc(&proceeded);
|
||||
|
||||
LOG("thread %d exiting\n", thread_id);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 1; i < argc; ++i) {
|
||||
const char *arg = argv[i];
|
||||
if (strcmp(arg, "-v") == 0) {
|
||||
++verbosity;
|
||||
} else {
|
||||
fprintf(stderr, "error: unrecognized option `%s`\n", arg);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
// Disable buffering
|
||||
setbuf(stdout, NULL);
|
||||
|
||||
LOG("pipe_barrier_test starting\n");
|
||||
|
||||
util_barrier_init(&barrier, NUM_THREADS);
|
||||
|
||||
for (i = 0; i < NUM_THREADS; i++) {
|
||||
thread_ids[i] = i;
|
||||
u_thread_create(threads + i, thread_function, (void *) &thread_ids[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < NUM_THREADS; i++ ) {
|
||||
thrd_join(threads[i], NULL);
|
||||
}
|
||||
|
||||
CHECK(p_atomic_read(&proceeded) == NUM_THREADS);
|
||||
|
||||
util_barrier_destroy(&barrier);
|
||||
|
||||
LOG("pipe_barrier_test exiting\n");
|
||||
|
||||
return 0;
|
||||
}
|
@@ -1,307 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright © 2010 Luca Barbieri
|
||||
*
|
||||
* 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 <stdio.h>
|
||||
#include "translate/translate.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "util/format/u_format.h"
|
||||
#include "util/half_float.h"
|
||||
#include "util/u_cpu_detect.h"
|
||||
|
||||
/* don't use this for serious use */
|
||||
static double rand_double()
|
||||
{
|
||||
const double rm = (double)RAND_MAX + 1;
|
||||
double div = 1;
|
||||
double v = 0;
|
||||
unsigned i;
|
||||
for(i = 0; i < 4; ++i)
|
||||
{
|
||||
div *= rm;
|
||||
v += (double)rand() / div;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
char cpu_caps_override_env[128];
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
struct translate *(*create_fn)(const struct translate_key *key) = 0;
|
||||
|
||||
struct translate_key key;
|
||||
unsigned output_format;
|
||||
unsigned input_format;
|
||||
unsigned buffer_size = 4096;
|
||||
unsigned char* buffer[5];
|
||||
unsigned char* byte_buffer;
|
||||
float* float_buffer;
|
||||
double* double_buffer;
|
||||
uint16_t *half_buffer;
|
||||
unsigned * elts;
|
||||
unsigned count = 4;
|
||||
unsigned i, j, k;
|
||||
unsigned passed = 0;
|
||||
unsigned total = 0;
|
||||
const float error = 0.03125;
|
||||
|
||||
create_fn = 0;
|
||||
|
||||
if (argc <= 1 ||
|
||||
!strcmp(argv[1], "default") )
|
||||
create_fn = translate_create;
|
||||
else if (!strcmp(argv[1], "generic"))
|
||||
create_fn = translate_generic_create;
|
||||
else if (!strcmp(argv[1], "x86"))
|
||||
create_fn = translate_sse2_create;
|
||||
else
|
||||
{
|
||||
const char *translate_options[] = {
|
||||
"nosse", "sse", "sse2", "sse3", "ssse3", "sse4.1", "avx",
|
||||
NULL
|
||||
};
|
||||
const char **option;
|
||||
for (option = translate_options; *option; ++option)
|
||||
{
|
||||
if (!strcmp(argv[1], *option))
|
||||
{
|
||||
create_fn = translate_sse2_create;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (create_fn) {
|
||||
snprintf(cpu_caps_override_env, sizeof(cpu_caps_override_env), "GALLIUM_OVERRIDE_CPU_CAPS=%s", argv[1]);
|
||||
putenv(cpu_caps_override_env);
|
||||
}
|
||||
}
|
||||
|
||||
if (!create_fn)
|
||||
{
|
||||
printf("Usage: ./translate_test [default|generic|x86|nosse|sse|sse2|sse3|ssse3|sse4.1|avx]\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
for (i = 1; i < ARRAY_SIZE(buffer); ++i)
|
||||
buffer[i] = align_malloc(buffer_size, 4096);
|
||||
|
||||
byte_buffer = align_malloc(buffer_size, 4096);
|
||||
float_buffer = align_malloc(buffer_size, 4096);
|
||||
double_buffer = align_malloc(buffer_size, 4096);
|
||||
half_buffer = align_malloc(buffer_size, 4096);
|
||||
|
||||
elts = align_malloc(count * sizeof *elts, 4096);
|
||||
|
||||
key.nr_elements = 1;
|
||||
key.element[0].input_buffer = 0;
|
||||
key.element[0].input_offset = 0;
|
||||
key.element[0].output_offset = 0;
|
||||
key.element[0].type = TRANSLATE_ELEMENT_NORMAL;
|
||||
key.element[0].instance_divisor = 0;
|
||||
|
||||
srand(4359025);
|
||||
|
||||
/* avoid negative values that work badly when converted to unsigned format*/
|
||||
for (i = 0; i < buffer_size; ++i)
|
||||
byte_buffer[i] = rand() & 0x7f7f7f7f;
|
||||
|
||||
for (i = 0; i < buffer_size / sizeof(float); ++i)
|
||||
float_buffer[i] = (float)rand_double();
|
||||
|
||||
for (i = 0; i < buffer_size / sizeof(double); ++i)
|
||||
double_buffer[i] = rand_double();
|
||||
|
||||
for (i = 0; i < buffer_size / sizeof(double); ++i)
|
||||
half_buffer[i] = _mesa_float_to_half((float) rand_double());
|
||||
|
||||
for (i = 0; i < count; ++i)
|
||||
elts[i] = i;
|
||||
|
||||
for (output_format = 1; output_format < PIPE_FORMAT_COUNT; ++output_format)
|
||||
{
|
||||
const struct util_format_description* output_format_desc = util_format_description(output_format);
|
||||
const struct util_format_pack_description* output_format_pack = util_format_pack_description(output_format);
|
||||
util_format_fetch_rgba_func_ptr fetch_rgba =
|
||||
util_format_fetch_rgba_func(output_format);
|
||||
unsigned output_format_size;
|
||||
unsigned output_normalized = 0;
|
||||
|
||||
if (!fetch_rgba
|
||||
|| !output_format_pack->pack_rgba_float
|
||||
|| output_format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB
|
||||
|| output_format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN
|
||||
|| !translate_is_output_format_supported(output_format))
|
||||
continue;
|
||||
|
||||
for(i = 0; i < output_format_desc->nr_channels; ++i)
|
||||
{
|
||||
if(output_format_desc->channel[i].type != UTIL_FORMAT_TYPE_FLOAT)
|
||||
output_normalized |= (1 << output_format_desc->channel[i].normalized);
|
||||
}
|
||||
|
||||
output_format_size = util_format_get_stride(output_format, 1);
|
||||
|
||||
for (input_format = 1; input_format < PIPE_FORMAT_COUNT; ++input_format)
|
||||
{
|
||||
const struct util_format_description* input_format_desc = util_format_description(input_format);
|
||||
const struct util_format_pack_description* input_format_pack = util_format_pack_description(input_format);
|
||||
util_format_fetch_rgba_func_ptr fetch_rgba =
|
||||
util_format_fetch_rgba_func(input_format);
|
||||
unsigned input_format_size;
|
||||
struct translate* translate[2];
|
||||
unsigned fail = 0;
|
||||
unsigned used_generic = 0;
|
||||
unsigned input_normalized = 0;
|
||||
bool input_is_float = false;
|
||||
|
||||
if (!fetch_rgba
|
||||
|| !input_format_pack->pack_rgba_float
|
||||
|| input_format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB
|
||||
|| input_format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN
|
||||
|| !translate_is_output_format_supported(input_format))
|
||||
continue;
|
||||
|
||||
input_format_size = util_format_get_stride(input_format, 1);
|
||||
|
||||
for(i = 0; i < input_format_desc->nr_channels; ++i)
|
||||
{
|
||||
if(input_format_desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT)
|
||||
{
|
||||
input_is_float = 1;
|
||||
input_normalized |= 1 << 1;
|
||||
}
|
||||
else
|
||||
input_normalized |= (1 << input_format_desc->channel[i].normalized);
|
||||
}
|
||||
|
||||
if(((input_normalized | output_normalized) == 3)
|
||||
|| ((input_normalized & 1) && (output_normalized & 1)
|
||||
&& input_format_size * output_format_desc->nr_channels > output_format_size * input_format_desc->nr_channels))
|
||||
continue;
|
||||
|
||||
key.element[0].input_format = input_format;
|
||||
key.element[0].output_format = output_format;
|
||||
key.output_stride = output_format_size;
|
||||
translate[0] = create_fn(&key);
|
||||
if (!translate[0])
|
||||
continue;
|
||||
|
||||
key.element[0].input_format = output_format;
|
||||
key.element[0].output_format = input_format;
|
||||
key.output_stride = input_format_size;
|
||||
translate[1] = create_fn(&key);
|
||||
if(!translate[1])
|
||||
{
|
||||
used_generic = 1;
|
||||
translate[1] = translate_generic_create(&key);
|
||||
if(!translate[1])
|
||||
continue;
|
||||
}
|
||||
|
||||
for(i = 1; i < 5; ++i)
|
||||
memset(buffer[i], 0xcd - (0x22 * i), 4096);
|
||||
|
||||
if(input_is_float && input_format_desc->channel[0].size == 32)
|
||||
buffer[0] = (unsigned char*)float_buffer;
|
||||
else if(input_is_float && input_format_desc->channel[0].size == 64)
|
||||
buffer[0] = (unsigned char*)double_buffer;
|
||||
else if(input_is_float && input_format_desc->channel[0].size == 16)
|
||||
buffer[0] = (unsigned char*)half_buffer;
|
||||
else if(input_is_float)
|
||||
abort();
|
||||
else
|
||||
buffer[0] = byte_buffer;
|
||||
|
||||
translate[0]->set_buffer(translate[0], 0, buffer[0], input_format_size, count - 1);
|
||||
translate[0]->run_elts(translate[0], elts, count, 0, 0, buffer[1]);
|
||||
translate[1]->set_buffer(translate[1], 0, buffer[1], output_format_size, count - 1);
|
||||
translate[1]->run_elts(translate[1], elts, count, 0, 0, buffer[2]);
|
||||
translate[0]->set_buffer(translate[0], 0, buffer[2], input_format_size, count - 1);
|
||||
translate[0]->run_elts(translate[0], elts, count, 0, 0, buffer[3]);
|
||||
translate[1]->set_buffer(translate[1], 0, buffer[3], output_format_size, count - 1);
|
||||
translate[1]->run_elts(translate[1], elts, count, 0, 0, buffer[4]);
|
||||
|
||||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
float a[4];
|
||||
float b[4];
|
||||
fetch_rgba(a, buffer[2] + i * input_format_size, 0, 0);
|
||||
fetch_rgba(b, buffer[4] + i * input_format_size, 0, 0);
|
||||
|
||||
for (j = 0; j < count; ++j)
|
||||
{
|
||||
float d = a[j] - b[j];
|
||||
if (d > error || d < -error)
|
||||
{
|
||||
fail = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf("%s%s: %s -> %s -> %s -> %s -> %s\n",
|
||||
fail ? "FAIL" : "PASS",
|
||||
used_generic ? "[GENERIC]" : "",
|
||||
input_format_desc->name, output_format_desc->name, input_format_desc->name, output_format_desc->name, input_format_desc->name);
|
||||
|
||||
if (1)
|
||||
{
|
||||
for (i = 0; i < ARRAY_SIZE(buffer); ++i)
|
||||
{
|
||||
unsigned format_size = (i & 1) ? output_format_size : input_format_size;
|
||||
printf("%c ", (i == 2 || i == 4) ? '*' : ' ');
|
||||
for (j = 0; j < count; ++j)
|
||||
{
|
||||
for (k = 0; k < format_size; ++k)
|
||||
{
|
||||
printf("%02x", buffer[i][j * format_size + k]);
|
||||
}
|
||||
printf(" ");
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (!fail)
|
||||
++passed;
|
||||
++total;
|
||||
|
||||
if(translate[1])
|
||||
translate[1]->release(translate[1]);
|
||||
translate[0]->release(translate[0]);
|
||||
}
|
||||
}
|
||||
|
||||
printf("%u/%u tests passed for translate_%s\n", passed, total, argv[1]);
|
||||
|
||||
for (i = 1; i < ARRAY_SIZE(buffer); ++i)
|
||||
align_free(buffer[i]);
|
||||
|
||||
align_free(byte_buffer);
|
||||
align_free(float_buffer);
|
||||
align_free(double_buffer);
|
||||
align_free(half_buffer);
|
||||
align_free(elts);
|
||||
return passed != total;
|
||||
}
|
@@ -1,122 +0,0 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2010 VMware, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* 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, sub license, 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 NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS 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.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/*
|
||||
* Test case for u_cache.
|
||||
*/
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "util/u_cache.h"
|
||||
#include "util/crc32.h"
|
||||
|
||||
|
||||
typedef uint32_t cache_test_key;
|
||||
typedef uint32_t cache_test_value;
|
||||
|
||||
|
||||
static uint32_t
|
||||
cache_test_hash(const void *key)
|
||||
{
|
||||
return util_hash_crc32(key, sizeof(cache_test_key));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
cache_test_destroy(void *key, void *value)
|
||||
{
|
||||
free(key);
|
||||
free(value);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
cache_test_compare(const void *key1, const void *key2) {
|
||||
return !(key1 == key2);
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
unsigned cache_size;
|
||||
unsigned cache_count;
|
||||
|
||||
for (cache_size = 2; cache_size < (1 << 15); cache_size *= 2) {
|
||||
for (cache_count = (cache_size << 5); cache_count < (cache_size << 10); cache_count *= 2) {
|
||||
struct util_cache * cache;
|
||||
cache_test_key *key;
|
||||
cache_test_value *value_in;
|
||||
cache_test_value *value_out;
|
||||
int i;
|
||||
|
||||
printf("Testing cache size of %d with %d values.\n", cache_size, cache_count);
|
||||
|
||||
cache = util_cache_create(cache_test_hash,
|
||||
cache_test_compare,
|
||||
cache_test_destroy,
|
||||
cache_size);
|
||||
|
||||
/*
|
||||
* Retrieve a value from an empty cache.
|
||||
*/
|
||||
key = malloc(sizeof(cache_test_key));
|
||||
*key = 0xdeadbeef;
|
||||
value_out = (cache_test_value *) util_cache_get(cache, key);
|
||||
assert(value_out == NULL);
|
||||
(void)value_out;
|
||||
free(key);
|
||||
|
||||
|
||||
/*
|
||||
* Repeatedly insert into and retrieve values from the cache.
|
||||
*/
|
||||
for (i = 0; i < cache_count; i++) {
|
||||
key = malloc(sizeof(cache_test_key));
|
||||
value_in = malloc(sizeof(cache_test_value));
|
||||
|
||||
*key = rand();
|
||||
*value_in = rand();
|
||||
util_cache_set(cache, key, value_in);
|
||||
|
||||
value_out = util_cache_get(cache, key);
|
||||
assert(value_out != NULL);
|
||||
assert(value_in == value_out);
|
||||
assert(*value_in == *value_out);
|
||||
}
|
||||
|
||||
/*
|
||||
* In debug builds, this will trigger a self-check by the cache of
|
||||
* the distribution of hits in its internal cache entries.
|
||||
*/
|
||||
util_cache_destroy(cache);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <float.h>
|
||||
|
||||
#include "util/u_math.h"
|
||||
#include "util/half_float.h"
|
||||
#include "util/u_cpu_detect.h"
|
||||
|
||||
static void
|
||||
test(void)
|
||||
{
|
||||
unsigned i;
|
||||
unsigned roundtrip_fails = 0;
|
||||
|
||||
for(i = 0; i < 1 << 16; ++i)
|
||||
{
|
||||
uint16_t h = (uint16_t) i;
|
||||
union fi f;
|
||||
uint16_t rh;
|
||||
|
||||
f.f = _mesa_half_to_float(h);
|
||||
rh = _mesa_float_to_half(f.f);
|
||||
|
||||
if (h != rh && !(util_is_half_nan(h) && util_is_half_nan(rh))) {
|
||||
printf("Roundtrip failed: %x -> %x = %f -> %x\n", h, f.ui, f.f, rh);
|
||||
++roundtrip_fails;
|
||||
}
|
||||
}
|
||||
|
||||
if(roundtrip_fails) {
|
||||
printf("Failure! %u/65536 half floats failed a conversion to float and back.\n", roundtrip_fails);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
test();
|
||||
|
||||
/* Test non-f16c. */
|
||||
if (util_get_cpu_caps()->has_f16c) {
|
||||
((struct util_cpu_caps_t *)util_get_cpu_caps())->has_f16c = false;
|
||||
test();
|
||||
}
|
||||
|
||||
printf("Success!\n");
|
||||
return 0;
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "util/u_prim.h"
|
||||
|
||||
struct test_info {
|
||||
enum mesa_prim prim_type;
|
||||
uint32_t count;
|
||||
uint32_t expected;
|
||||
};
|
||||
|
||||
struct test_info tests[] = {
|
||||
{ MESA_PRIM_POINTS, 0, 0 },
|
||||
{ MESA_PRIM_POINTS, 1, 1 },
|
||||
{ MESA_PRIM_POINTS, 2, 2 },
|
||||
|
||||
{ MESA_PRIM_LINES, 0, 0 },
|
||||
{ MESA_PRIM_LINES, 1, 2 },
|
||||
{ MESA_PRIM_LINES, 2, 4 },
|
||||
|
||||
{ MESA_PRIM_TRIANGLES, 0, 0 },
|
||||
{ MESA_PRIM_TRIANGLES, 1, 3 },
|
||||
{ MESA_PRIM_TRIANGLES, 2, 6 },
|
||||
|
||||
{ MESA_PRIM_QUADS, 0, 0 },
|
||||
{ MESA_PRIM_QUADS, 1, 4 },
|
||||
{ MESA_PRIM_QUADS, 2, 8 },
|
||||
};
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
for(int i = 0; i < ARRAY_SIZE(tests); i++) {
|
||||
struct test_info *info = &tests[i];
|
||||
uint32_t n = u_vertices_for_prims(info->prim_type, info->count);
|
||||
if (n != info->expected) {
|
||||
printf("Failure! Expected %u vertices for %u x %s, but got %u.\n",
|
||||
info->expected, info->count, u_prim_name(info->prim_type), n);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
printf("Success!\n");
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user