struct pipe_vertex_element velem[2];
void *vs;
- void *fs[PIPE_MAX_TEXTURE_TYPES][TGSI_WRITEMASK_XYZW + 1];
+ void *fs[PIPE_MAX_TEXTURE_TYPES][TGSI_WRITEMASK_XYZW + 1][3];
struct pipe_resource *vbuf; /**< quad vertices */
unsigned vbuf_slot;
util_destroy_blit(struct blit_state *ctx)
{
struct pipe_context *pipe = ctx->pipe;
- unsigned i, j;
+ unsigned i, j, k;
if (ctx->vs)
pipe->delete_vs_state(pipe, ctx->vs);
for (i = 0; i < Elements(ctx->fs); i++) {
for (j = 0; j < Elements(ctx->fs[i]); j++) {
- if (ctx->fs[i][j])
- pipe->delete_fs_state(pipe, ctx->fs[i][j]);
+ for (k = 0; k < Elements(ctx->fs[i][j]); k++) {
+ if (ctx->fs[i][j][k])
+ pipe->delete_fs_state(pipe, ctx->fs[i][j][k]);
+ }
}
}
*/
static INLINE void
set_fragment_shader(struct blit_state *ctx, uint writemask,
+ enum pipe_format format,
enum pipe_texture_target pipe_tex)
{
- if (!ctx->fs[pipe_tex][writemask]) {
+ enum tgsi_return_type stype;
+ unsigned idx;
+
+ if (util_format_is_pure_uint(format)) {
+ stype = TGSI_RETURN_TYPE_UINT;
+ idx = 0;
+ } else if (util_format_is_pure_sint(format)) {
+ stype = TGSI_RETURN_TYPE_SINT;
+ idx = 1;
+ } else {
+ stype = TGSI_RETURN_TYPE_FLOAT;
+ idx = 2;
+ }
+
+ if (!ctx->fs[pipe_tex][writemask][idx]) {
unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(pipe_tex, 0);
- ctx->fs[pipe_tex][writemask] =
+ ctx->fs[pipe_tex][writemask][idx] =
util_make_fragment_tex_shader_writemask(ctx->pipe, tgsi_tex,
TGSI_INTERPOLATE_LINEAR,
- writemask);
+ writemask,
+ stype);
}
- cso_set_fragment_shader_handle(ctx->cso, ctx->fs[pipe_tex][writemask]);
+ cso_set_fragment_shader_handle(ctx->cso, ctx->fs[pipe_tex][writemask][idx]);
}
/* shaders */
set_fragment_shader(ctx, TGSI_WRITEMASK_XYZW,
+ src_sampler_view->format,
src_sampler_view->texture->target);
set_vertex_shader(ctx);
cso_set_tessctrl_shader_handle(ctx->cso, NULL);
/* FS which outputs a color from a texture,
where the index is PIPE_TEXTURE_* to be sampled. */
void *fs_texfetch_col[PIPE_MAX_TEXTURE_TYPES];
+ void *fs_texfetch_col_uint[PIPE_MAX_TEXTURE_TYPES];
+ void *fs_texfetch_col_sint[PIPE_MAX_TEXTURE_TYPES];
/* FS which outputs a depth from a texture,
where the index is PIPE_TEXTURE_* to be sampled. */
/* FS which outputs one sample from a multisample texture. */
void *fs_texfetch_col_msaa[PIPE_MAX_TEXTURE_TYPES];
+ void *fs_texfetch_col_msaa_uint[PIPE_MAX_TEXTURE_TYPES];
+ void *fs_texfetch_col_msaa_sint[PIPE_MAX_TEXTURE_TYPES];
void *fs_texfetch_depth_msaa[PIPE_MAX_TEXTURE_TYPES];
void *fs_texfetch_depthstencil_msaa[PIPE_MAX_TEXTURE_TYPES];
void *fs_texfetch_stencil_msaa[PIPE_MAX_TEXTURE_TYPES];
for (i = 0; i < PIPE_MAX_TEXTURE_TYPES; i++) {
if (ctx->fs_texfetch_col[i])
ctx->delete_fs_state(pipe, ctx->fs_texfetch_col[i]);
+ if (ctx->fs_texfetch_col_sint[i])
+ ctx->delete_fs_state(pipe, ctx->fs_texfetch_col_sint[i]);
+ if (ctx->fs_texfetch_col_uint[i])
+ ctx->delete_fs_state(pipe, ctx->fs_texfetch_col_uint[i]);
if (ctx->fs_texfetch_depth[i])
ctx->delete_fs_state(pipe, ctx->fs_texfetch_depth[i]);
if (ctx->fs_texfetch_depthstencil[i])
if (ctx->fs_texfetch_col_msaa[i])
ctx->delete_fs_state(pipe, ctx->fs_texfetch_col_msaa[i]);
+ if (ctx->fs_texfetch_col_msaa_sint[i])
+ ctx->delete_fs_state(pipe, ctx->fs_texfetch_col_msaa_sint[i]);
+ if (ctx->fs_texfetch_col_msaa_uint[i])
+ ctx->delete_fs_state(pipe, ctx->fs_texfetch_col_msaa_uint[i]);
if (ctx->fs_texfetch_depth_msaa[i])
ctx->delete_fs_state(pipe, ctx->fs_texfetch_depth_msaa[i]);
if (ctx->fs_texfetch_depthstencil_msaa[i])
{
struct pipe_context *pipe = ctx->base.pipe;
unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(target, src_nr_samples);
+ enum tgsi_return_type stype;
assert(target < PIPE_MAX_TEXTURE_TYPES);
+ if (util_format_is_pure_uint(format))
+ stype = TGSI_RETURN_TYPE_UINT;
+ else if (util_format_is_pure_sint(format))
+ stype = TGSI_RETURN_TYPE_SINT;
+ else
+ stype = TGSI_RETURN_TYPE_FLOAT;
+
if (src_nr_samples > 1) {
void **shader;
if (dst_nr_samples <= 1) {
/* The destination has one sample, so we'll do color resolve. */
- boolean is_uint, is_sint;
unsigned index = GET_MSAA_RESOLVE_FS_IDX(src_nr_samples);
- is_uint = util_format_is_pure_uint(format);
- is_sint = util_format_is_pure_sint(format);
-
assert(filter < 2);
- if (is_uint)
+ if (stype == TGSI_RETURN_TYPE_UINT)
shader = &ctx->fs_resolve_uint[target][index][filter];
- else if (is_sint)
+ else if (stype == TGSI_RETURN_TYPE_SINT)
shader = &ctx->fs_resolve_sint[target][index][filter];
else
shader = &ctx->fs_resolve[target][index][filter];
if (filter == PIPE_TEX_FILTER_LINEAR) {
*shader = util_make_fs_msaa_resolve_bilinear(pipe, tgsi_tex,
src_nr_samples,
- is_uint, is_sint);
+ stype);
}
else {
*shader = util_make_fs_msaa_resolve(pipe, tgsi_tex,
src_nr_samples,
- is_uint, is_sint);
+ stype);
}
}
}
/* The destination has multiple samples, we'll do
* an MSAA->MSAA copy.
*/
- shader = &ctx->fs_texfetch_col_msaa[target];
+ if (stype == TGSI_RETURN_TYPE_UINT)
+ shader = &ctx->fs_texfetch_col_msaa_uint[target];
+ else if (stype == TGSI_RETURN_TYPE_SINT)
+ shader = &ctx->fs_texfetch_col_msaa_sint[target];
+ else
+ shader = &ctx->fs_texfetch_col_msaa[target];
/* Create the fragment shader on-demand. */
if (!*shader) {
assert(!ctx->cached_all_shaders);
- *shader = util_make_fs_blit_msaa_color(pipe, tgsi_tex);
+ *shader = util_make_fs_blit_msaa_color(pipe, tgsi_tex, stype);
}
}
return *shader;
} else {
- void **shader = &ctx->fs_texfetch_col[target];
+ void **shader;
+
+ if (stype == TGSI_RETURN_TYPE_UINT)
+ shader = &ctx->fs_texfetch_col_uint[target];
+ else if (stype == TGSI_RETURN_TYPE_SINT)
+ shader = &ctx->fs_texfetch_col_sint[target];
+ else
+ shader = &ctx->fs_texfetch_col[target];
/* Create the fragment shader on-demand. */
if (!*shader) {
assert(!ctx->cached_all_shaders);
*shader = util_make_fragment_tex_shader(pipe, tgsi_tex,
- TGSI_INTERPOLATE_LINEAR);
+ TGSI_INTERPOLATE_LINEAR,
+ stype);
}
return *shader;
*/
blitter_get_fs_texfetch_col(ctx, PIPE_FORMAT_R32_FLOAT, target,
samples, samples, 0);
+ blitter_get_fs_texfetch_col(ctx, PIPE_FORMAT_R32_UINT, target,
+ samples, samples, 0);
+ blitter_get_fs_texfetch_col(ctx, PIPE_FORMAT_R32_SINT, target,
+ samples, samples, 0);
blitter_get_fs_texfetch_depth(ctx, target, samples);
if (ctx->has_stencil_export) {
blitter_get_fs_texfetch_depthstencil(ctx, target, samples);
util_make_fragment_tex_shader_writemask(struct pipe_context *pipe,
unsigned tex_target,
unsigned interp_mode,
- unsigned writemask )
+ unsigned writemask,
+ enum tgsi_return_type stype)
{
struct ureg_program *ureg;
struct ureg_src sampler;
sampler = ureg_DECL_sampler( ureg, 0 );
+ ureg_DECL_sampler_view(ureg, 0, tex_target, stype, stype, stype, stype);
+
tex = ureg_DECL_fs_input( ureg,
TGSI_SEMANTIC_GENERIC, 0,
interp_mode );
*/
void *
util_make_fragment_tex_shader(struct pipe_context *pipe, unsigned tex_target,
- unsigned interp_mode)
+ unsigned interp_mode,
+ enum tgsi_return_type stype)
{
return util_make_fragment_tex_shader_writemask( pipe,
tex_target,
interp_mode,
- TGSI_WRITEMASK_XYZW );
+ TGSI_WRITEMASK_XYZW,
+ stype );
}
sampler = ureg_DECL_sampler( ureg, 0 );
+ ureg_DECL_sampler_view(ureg, 0, tex_target,
+ TGSI_RETURN_TYPE_FLOAT,
+ TGSI_RETURN_TYPE_FLOAT,
+ TGSI_RETURN_TYPE_FLOAT,
+ TGSI_RETURN_TYPE_FLOAT);
+
tex = ureg_DECL_fs_input( ureg,
TGSI_SEMANTIC_GENERIC, 0,
interp_mode );
return NULL;
depth_sampler = ureg_DECL_sampler( ureg, 0 );
+ ureg_DECL_sampler_view(ureg, 0, tex_target,
+ TGSI_RETURN_TYPE_FLOAT,
+ TGSI_RETURN_TYPE_FLOAT,
+ TGSI_RETURN_TYPE_FLOAT,
+ TGSI_RETURN_TYPE_FLOAT);
stencil_sampler = ureg_DECL_sampler( ureg, 1 );
+ ureg_DECL_sampler_view(ureg, 0, tex_target,
+ TGSI_RETURN_TYPE_UINT,
+ TGSI_RETURN_TYPE_UINT,
+ TGSI_RETURN_TYPE_UINT,
+ TGSI_RETURN_TYPE_UINT);
tex = ureg_DECL_fs_input( ureg,
TGSI_SEMANTIC_GENERIC, 0,
stencil_sampler = ureg_DECL_sampler( ureg, 0 );
+ ureg_DECL_sampler_view(ureg, 0, tex_target,
+ TGSI_RETURN_TYPE_UINT,
+ TGSI_RETURN_TYPE_UINT,
+ TGSI_RETURN_TYPE_UINT,
+ TGSI_RETURN_TYPE_UINT);
+
tex = ureg_DECL_fs_input( ureg,
TGSI_SEMANTIC_GENERIC, 0,
interp_mode );
static void *
util_make_fs_blit_msaa_gen(struct pipe_context *pipe,
unsigned tgsi_tex,
+ const char *samp_type,
const char *output_semantic,
const char *output_mask)
{
"FRAG\n"
"DCL IN[0], GENERIC[0], LINEAR\n"
"DCL SAMP[0]\n"
+ "DCL SVIEW[0], %s, %s\n"
"DCL OUT[0], %s\n"
"DCL TEMP[0]\n"
assert(tgsi_tex == TGSI_TEXTURE_2D_MSAA ||
tgsi_tex == TGSI_TEXTURE_2D_ARRAY_MSAA);
- sprintf(text, shader_templ, output_semantic, output_mask, type);
+ sprintf(text, shader_templ, type, samp_type,
+ output_semantic, output_mask, type);
if (!tgsi_text_translate(text, tokens, Elements(tokens))) {
puts(text);
*/
void *
util_make_fs_blit_msaa_color(struct pipe_context *pipe,
- unsigned tgsi_tex)
+ unsigned tgsi_tex,
+ enum tgsi_return_type stype)
{
- return util_make_fs_blit_msaa_gen(pipe, tgsi_tex,
+ const char *samp_type;
+
+ if (stype == TGSI_RETURN_TYPE_UINT)
+ samp_type = "UINT";
+ else if (stype == TGSI_RETURN_TYPE_SINT)
+ samp_type = "SINT";
+ else
+ samp_type = "FLOAT";
+
+ return util_make_fs_blit_msaa_gen(pipe, tgsi_tex, samp_type,
"COLOR[0]", "");
}
util_make_fs_blit_msaa_depth(struct pipe_context *pipe,
unsigned tgsi_tex)
{
- return util_make_fs_blit_msaa_gen(pipe, tgsi_tex,
+ return util_make_fs_blit_msaa_gen(pipe, tgsi_tex, "FLOAT",
"POSITION", ".z");
}
util_make_fs_blit_msaa_stencil(struct pipe_context *pipe,
unsigned tgsi_tex)
{
- return util_make_fs_blit_msaa_gen(pipe, tgsi_tex,
+ return util_make_fs_blit_msaa_gen(pipe, tgsi_tex, "UINT",
"STENCIL", ".y");
}
void *
util_make_fs_msaa_resolve(struct pipe_context *pipe,
unsigned tgsi_tex, unsigned nr_samples,
- boolean is_uint, boolean is_sint)
+ enum tgsi_return_type stype)
{
struct ureg_program *ureg;
struct ureg_src sampler, coord;
/* Declarations. */
sampler = ureg_DECL_sampler(ureg, 0);
+ ureg_DECL_sampler_view(ureg, 0, tgsi_tex, stype, stype, stype, stype);
coord = ureg_DECL_fs_input(ureg, TGSI_SEMANTIC_GENERIC, 0,
TGSI_INTERPOLATE_LINEAR);
out = ureg_DECL_output(ureg, TGSI_SEMANTIC_COLOR, 0);
ureg_imm1u(ureg, i));
ureg_TXF(ureg, tmp, tgsi_tex, ureg_src(tmp_coord), sampler);
- if (is_uint)
+ if (stype == TGSI_RETURN_TYPE_UINT)
ureg_U2F(ureg, tmp, ureg_src(tmp));
- else if (is_sint)
+ else if (stype == TGSI_RETURN_TYPE_SINT)
ureg_I2F(ureg, tmp, ureg_src(tmp));
/* Add it to the sum.*/
ureg_MUL(ureg, tmp_sum, ureg_src(tmp_sum),
ureg_imm1f(ureg, 1.0 / nr_samples));
- if (is_uint)
+ if (stype == TGSI_RETURN_TYPE_UINT)
ureg_F2U(ureg, out, ureg_src(tmp_sum));
- else if (is_sint)
+ else if (stype == TGSI_RETURN_TYPE_SINT)
ureg_F2I(ureg, out, ureg_src(tmp_sum));
else
ureg_MOV(ureg, out, ureg_src(tmp_sum));
void *
util_make_fs_msaa_resolve_bilinear(struct pipe_context *pipe,
unsigned tgsi_tex, unsigned nr_samples,
- boolean is_uint, boolean is_sint)
+ enum tgsi_return_type stype)
{
struct ureg_program *ureg;
struct ureg_src sampler, coord;
/* Declarations. */
sampler = ureg_DECL_sampler(ureg, 0);
+ ureg_DECL_sampler_view(ureg, 0, tgsi_tex, stype, stype, stype, stype);
coord = ureg_DECL_fs_input(ureg, TGSI_SEMANTIC_GENERIC, 0,
TGSI_INTERPOLATE_LINEAR);
out = ureg_DECL_output(ureg, TGSI_SEMANTIC_COLOR, 0);
ureg_imm1u(ureg, i));
ureg_TXF(ureg, tmp, tgsi_tex, ureg_src(tmp_coord[c]), sampler);
- if (is_uint)
+ if (stype == TGSI_RETURN_TYPE_UINT)
ureg_U2F(ureg, tmp, ureg_src(tmp));
- else if (is_sint)
+ else if (stype == TGSI_RETURN_TYPE_SINT)
ureg_I2F(ureg, tmp, ureg_src(tmp));
/* Add it to the sum.*/
ureg_src(top));
/* Convert to the texture format and return. */
- if (is_uint)
+ if (stype == TGSI_RETURN_TYPE_UINT)
ureg_F2U(ureg, out, ureg_src(tmp));
- else if (is_sint)
+ else if (stype == TGSI_RETURN_TYPE_SINT)
ureg_F2I(ureg, out, ureg_src(tmp));
else
ureg_MOV(ureg, out, ureg_src(tmp));
util_make_layered_clear_geometry_shader(struct pipe_context *pipe);
extern void *
-util_make_fragment_tex_shader_writemask(struct pipe_context *pipe,
+util_make_fragment_tex_shader_writemask(struct pipe_context *pipe,
unsigned tex_target,
unsigned interp_mode,
- unsigned writemask);
+ unsigned writemask,
+ enum tgsi_return_type stype);
extern void *
util_make_fragment_tex_shader(struct pipe_context *pipe, unsigned tex_target,
- unsigned interp_mode);
-
+ unsigned interp_mode,
+ enum tgsi_return_type stype);
extern void *
util_make_fragment_tex_shader_writedepth(struct pipe_context *pipe,
extern void *
util_make_fs_blit_msaa_color(struct pipe_context *pipe,
- unsigned tgsi_tex);
+ unsigned tgsi_tex,
+ enum tgsi_return_type stype);
extern void *
void *
util_make_fs_msaa_resolve(struct pipe_context *pipe,
unsigned tgsi_tex, unsigned nr_samples,
- boolean is_uint, boolean is_sint);
+ enum tgsi_return_type stype);
void *
util_make_fs_msaa_resolve_bilinear(struct pipe_context *pipe,
unsigned tgsi_tex, unsigned nr_samples,
- boolean is_uint, boolean is_sint);
+ enum tgsi_return_type stype);
#ifdef __cplusplus
}
/* Fragment shader. */
fs = util_make_fragment_tex_shader(ctx, tgsi_tex_target,
- TGSI_INTERPOLATE_LINEAR);
+ TGSI_INTERPOLATE_LINEAR,
+ TGSI_RETURN_TYPE_FLOAT);
cso_set_fragment_shader_handle(cso, fs);
/* Vertex shader. */
}
/* fragment shader */
- p->fs = util_make_fragment_tex_shader(p->pipe, TGSI_TEXTURE_2D, TGSI_INTERPOLATE_LINEAR);
+ p->fs = util_make_fragment_tex_shader(p->pipe, TGSI_TEXTURE_2D,
+ TGSI_INTERPOLATE_LINEAR,
+ TGSI_RETURN_TYPE_FLOAT);
}
static void close_prog(struct program *p)