summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/auxiliary/util/u_simple_shaders.c
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2018-01-08 05:41:34 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2018-01-08 05:41:34 +0000
commitc00801de923e125863aaf8180439d59d610b2517 (patch)
treee2896aa2785f3cf2151aeeb3c95fb5cc09a2fe02 /lib/mesa/src/gallium/auxiliary/util/u_simple_shaders.c
parentbe30e6efb92db21299b936c0e068e7088941e9c9 (diff)
Revert to Mesa 13.0.6 again.
Corruption has again been reported on Intel hardware running Xorg with the modesetting driver (which uses OpenGL based acceleration instead of SNA acceleration the intel driver defaults to). Reported in various forms on Sandy Bridge (X220), Ivy Bridge (X230) and Haswell (X240). Confirmed to not occur with the intel driver but the xserver was changed to default to the modesetting driver on >= gen4 hardware (except Ironlake). One means of triggering this is to open a large pdf with xpdf on an idle machine and highlight a section of the document. There have been reports of gpu hangs on gen4 intel hardware (T500 with GM45, X61 with 965GM) when starting Xorg as well.
Diffstat (limited to 'lib/mesa/src/gallium/auxiliary/util/u_simple_shaders.c')
-rw-r--r--lib/mesa/src/gallium/auxiliary/util/u_simple_shaders.c147
1 files changed, 37 insertions, 110 deletions
diff --git a/lib/mesa/src/gallium/auxiliary/util/u_simple_shaders.c b/lib/mesa/src/gallium/auxiliary/util/u_simple_shaders.c
index 79331b563..1220e187e 100644
--- a/lib/mesa/src/gallium/auxiliary/util/u_simple_shaders.c
+++ b/lib/mesa/src/gallium/auxiliary/util/u_simple_shaders.c
@@ -41,7 +41,6 @@
#include "util/u_simple_shaders.h"
#include "util/u_debug.h"
#include "util/u_memory.h"
-#include "util/u_string.h"
#include "tgsi/tgsi_dump.h"
#include "tgsi/tgsi_strings.h"
#include "tgsi/tgsi_ureg.h"
@@ -119,7 +118,7 @@ void *util_make_layered_clear_vertex_shader(struct pipe_context *pipe)
"MOV OUT[0], IN[0]\n"
"MOV OUT[1], IN[1]\n"
- "MOV OUT[2].x, SV[0].xxxx\n"
+ "MOV OUT[2], SV[0]\n"
"END\n";
struct tgsi_token tokens[1000];
struct pipe_shader_state state;
@@ -205,35 +204,11 @@ void *util_make_layered_clear_geometry_shader(struct pipe_context *pipe)
return pipe->create_gs_state(pipe, &state);
}
-static void
-ureg_load_tex(struct ureg_program *ureg, struct ureg_dst out,
- struct ureg_src coord, struct ureg_src sampler,
- unsigned tex_target, bool load_level_zero, bool use_txf)
-{
- if (use_txf) {
- struct ureg_dst temp = ureg_DECL_temporary(ureg);
-
- ureg_F2I(ureg, temp, coord);
-
- if (load_level_zero)
- ureg_TXF_LZ(ureg, out, tex_target, ureg_src(temp), sampler);
- else
- ureg_TXF(ureg, out, tex_target, ureg_src(temp), sampler);
- } else {
- if (load_level_zero)
- ureg_TEX_LZ(ureg, out, tex_target, coord, sampler);
- else
- ureg_TEX(ureg, out, tex_target, coord, sampler);
- }
-}
-
/**
* Make simple fragment texture shader:
* IMM {0,0,0,1} // (if writemask != 0xf)
- * MOV TEMP[0], IMM[0] // (if writemask != 0xf)
- * TEX TEMP[0].writemask, IN[0], SAMP[0], 2D;
- * .. optional SINT <-> UINT clamping ..
- * MOV OUT[0], TEMP[0]
+ * MOV OUT[0], IMM[0] // (if writemask != 0xf)
+ * TEX OUT[0].writemask, IN[0], SAMP[0], 2D;
* END;
*
* \param tex_target one of PIPE_TEXTURE_x
@@ -245,18 +220,13 @@ util_make_fragment_tex_shader_writemask(struct pipe_context *pipe,
unsigned tex_target,
unsigned interp_mode,
unsigned writemask,
- enum tgsi_return_type stype,
- enum tgsi_return_type dtype,
- bool load_level_zero,
- bool use_txf)
+ enum tgsi_return_type stype)
{
struct ureg_program *ureg;
struct ureg_src sampler;
struct ureg_src tex;
- struct ureg_dst temp;
struct ureg_dst out;
- assert((stype == TGSI_RETURN_TYPE_FLOAT) == (dtype == TGSI_RETURN_TYPE_FLOAT));
assert(interp_mode == TGSI_INTERPOLATE_LINEAR ||
interp_mode == TGSI_INTERPOLATE_PERSPECTIVE);
@@ -276,8 +246,6 @@ util_make_fragment_tex_shader_writemask(struct pipe_context *pipe,
TGSI_SEMANTIC_COLOR,
0 );
- temp = ureg_DECL_temporary(ureg);
-
if (writemask != TGSI_WRITEMASK_XYZW) {
struct ureg_src imm = ureg_imm4f( ureg, 0, 0, 0, 1 );
@@ -286,26 +254,12 @@ util_make_fragment_tex_shader_writemask(struct pipe_context *pipe,
if (tex_target == TGSI_TEXTURE_BUFFER)
ureg_TXF(ureg,
- ureg_writemask(temp, writemask),
+ ureg_writemask(out, writemask),
tex_target, tex, sampler);
else
- ureg_load_tex(ureg, ureg_writemask(temp, writemask), tex, sampler,
- tex_target, load_level_zero, use_txf);
-
- if (stype != dtype) {
- if (stype == TGSI_RETURN_TYPE_SINT) {
- assert(dtype == TGSI_RETURN_TYPE_UINT);
-
- ureg_IMAX(ureg, temp, ureg_src(temp), ureg_imm1i(ureg, 0));
- } else {
- assert(stype == TGSI_RETURN_TYPE_UINT);
- assert(dtype == TGSI_RETURN_TYPE_SINT);
-
- ureg_UMIN(ureg, temp, ureg_src(temp), ureg_imm1u(ureg, (1u << 31) - 1));
- }
- }
-
- ureg_MOV(ureg, out, ureg_src(temp));
+ ureg_TEX(ureg,
+ ureg_writemask(out, writemask),
+ tex_target, tex, sampler);
ureg_END( ureg );
@@ -321,17 +275,13 @@ util_make_fragment_tex_shader_writemask(struct pipe_context *pipe,
void *
util_make_fragment_tex_shader(struct pipe_context *pipe, unsigned tex_target,
unsigned interp_mode,
- enum tgsi_return_type stype,
- enum tgsi_return_type dtype,
- bool load_level_zero,
- bool use_txf)
+ enum tgsi_return_type stype)
{
return util_make_fragment_tex_shader_writemask( pipe,
tex_target,
interp_mode,
TGSI_WRITEMASK_XYZW,
- stype, dtype, load_level_zero,
- use_txf);
+ stype );
}
@@ -342,9 +292,7 @@ util_make_fragment_tex_shader(struct pipe_context *pipe, unsigned tex_target,
void *
util_make_fragment_tex_shader_writedepth(struct pipe_context *pipe,
unsigned tex_target,
- unsigned interp_mode,
- bool load_level_zero,
- bool use_txf)
+ unsigned interp_mode)
{
struct ureg_program *ureg;
struct ureg_src sampler;
@@ -380,8 +328,9 @@ util_make_fragment_tex_shader_writedepth(struct pipe_context *pipe,
ureg_MOV( ureg, out, imm );
- ureg_load_tex(ureg, ureg_writemask(depth, TGSI_WRITEMASK_Z), tex, sampler,
- tex_target, load_level_zero, use_txf);
+ ureg_TEX( ureg,
+ ureg_writemask(depth, TGSI_WRITEMASK_Z),
+ tex_target, tex, sampler );
ureg_END( ureg );
return ureg_create_shader_and_destroy( ureg, pipe );
@@ -395,9 +344,7 @@ util_make_fragment_tex_shader_writedepth(struct pipe_context *pipe,
void *
util_make_fragment_tex_shader_writedepthstencil(struct pipe_context *pipe,
unsigned tex_target,
- unsigned interp_mode,
- bool load_level_zero,
- bool use_txf)
+ unsigned interp_mode)
{
struct ureg_program *ureg;
struct ureg_src depth_sampler, stencil_sampler;
@@ -442,10 +389,12 @@ util_make_fragment_tex_shader_writedepthstencil(struct pipe_context *pipe,
ureg_MOV( ureg, out, imm );
- ureg_load_tex(ureg, ureg_writemask(depth, TGSI_WRITEMASK_Z), tex,
- depth_sampler, tex_target, load_level_zero, use_txf);
- ureg_load_tex(ureg, ureg_writemask(stencil, TGSI_WRITEMASK_Y), tex,
- stencil_sampler, tex_target, load_level_zero, use_txf);
+ ureg_TEX( ureg,
+ ureg_writemask(depth, TGSI_WRITEMASK_Z),
+ tex_target, tex, depth_sampler );
+ ureg_TEX( ureg,
+ ureg_writemask(stencil, TGSI_WRITEMASK_Y),
+ tex_target, tex, stencil_sampler );
ureg_END( ureg );
return ureg_create_shader_and_destroy( ureg, pipe );
@@ -459,9 +408,7 @@ util_make_fragment_tex_shader_writedepthstencil(struct pipe_context *pipe,
void *
util_make_fragment_tex_shader_writestencil(struct pipe_context *pipe,
unsigned tex_target,
- unsigned interp_mode,
- bool load_level_zero,
- bool use_txf)
+ unsigned interp_mode)
{
struct ureg_program *ureg;
struct ureg_src stencil_sampler;
@@ -497,8 +444,9 @@ util_make_fragment_tex_shader_writestencil(struct pipe_context *pipe,
ureg_MOV( ureg, out, imm );
- ureg_load_tex(ureg, ureg_writemask(stencil, TGSI_WRITEMASK_Y), tex,
- stencil_sampler, tex_target, load_level_zero, use_txf);
+ ureg_TEX( ureg,
+ ureg_writemask(stencil, TGSI_WRITEMASK_Y),
+ tex_target, tex, stencil_sampler );
ureg_END( ureg );
return ureg_create_shader_and_destroy( ureg, pipe );
@@ -597,9 +545,7 @@ 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,
- const char *conversion_decl,
- const char *conversion)
+ const char *output_mask)
{
static const char shader_templ[] =
"FRAG\n"
@@ -608,12 +554,9 @@ util_make_fs_blit_msaa_gen(struct pipe_context *pipe,
"DCL SVIEW[0], %s, %s\n"
"DCL OUT[0], %s\n"
"DCL TEMP[0]\n"
- "%s"
"F2U TEMP[0], IN[0]\n"
- "TXF TEMP[0], TEMP[0], SAMP[0], %s\n"
- "%s"
- "MOV OUT[0]%s, TEMP[0]\n"
+ "TXF OUT[0]%s, TEMP[0], SAMP[0], %s\n"
"END\n";
const char *type = tgsi_texture_names[tgsi_tex];
@@ -624,8 +567,8 @@ util_make_fs_blit_msaa_gen(struct pipe_context *pipe,
assert(tgsi_tex == TGSI_TEXTURE_2D_MSAA ||
tgsi_tex == TGSI_TEXTURE_2D_ARRAY_MSAA);
- util_snprintf(text, sizeof(text), shader_templ, type, samp_type,
- output_semantic, conversion_decl, type, conversion, output_mask);
+ sprintf(text, shader_templ, type, samp_type,
+ output_semantic, output_mask, type);
if (!tgsi_text_translate(text, tokens, ARRAY_SIZE(tokens))) {
puts(text);
@@ -649,35 +592,19 @@ util_make_fs_blit_msaa_gen(struct pipe_context *pipe,
void *
util_make_fs_blit_msaa_color(struct pipe_context *pipe,
unsigned tgsi_tex,
- enum tgsi_return_type stype,
- enum tgsi_return_type dtype)
+ enum tgsi_return_type stype)
{
const char *samp_type;
- const char *conversion_decl = "";
- const char *conversion = "";
- if (stype == TGSI_RETURN_TYPE_UINT) {
+ if (stype == TGSI_RETURN_TYPE_UINT)
samp_type = "UINT";
-
- if (dtype == TGSI_RETURN_TYPE_SINT) {
- conversion_decl = "IMM[0] UINT32 {2147483647, 0, 0, 0}\n";
- conversion = "UMIN TEMP[0], TEMP[0], IMM[0].xxxx\n";
- }
- } else if (stype == TGSI_RETURN_TYPE_SINT) {
+ else if (stype == TGSI_RETURN_TYPE_SINT)
samp_type = "SINT";
-
- if (dtype == TGSI_RETURN_TYPE_UINT) {
- conversion_decl = "IMM[0] INT32 {0, 0, 0, 0}\n";
- conversion = "IMAX TEMP[0], TEMP[0], IMM[0].xxxx\n";
- }
- } else {
- assert(dtype == TGSI_RETURN_TYPE_FLOAT);
+ else
samp_type = "FLOAT";
- }
return util_make_fs_blit_msaa_gen(pipe, tgsi_tex, samp_type,
- "COLOR[0]", "", conversion_decl,
- conversion);
+ "COLOR[0]", "");
}
@@ -691,7 +618,7 @@ util_make_fs_blit_msaa_depth(struct pipe_context *pipe,
unsigned tgsi_tex)
{
return util_make_fs_blit_msaa_gen(pipe, tgsi_tex, "FLOAT",
- "POSITION", ".z", "", "");
+ "POSITION", ".z");
}
@@ -705,7 +632,7 @@ util_make_fs_blit_msaa_stencil(struct pipe_context *pipe,
unsigned tgsi_tex)
{
return util_make_fs_blit_msaa_gen(pipe, tgsi_tex, "UINT",
- "STENCIL", ".y", "", "");
+ "STENCIL", ".y");
}
@@ -954,7 +881,7 @@ util_make_geometry_passthrough_shader(struct pipe_context *pipe,
}
/* EMIT IMM[0] */
- ureg_insn(ureg, TGSI_OPCODE_EMIT, NULL, 0, &imm, 1, 0);
+ ureg_insn(ureg, TGSI_OPCODE_EMIT, NULL, 0, &imm, 1);
/* END */
ureg_END(ureg);