diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2017-08-26 16:59:42 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2017-08-26 16:59:42 +0000 |
commit | 81ece42815e80818f160cdd85fab57d65b56ad15 (patch) | |
tree | 1059ff094da1aa50334115952fcb1cfcbda3acc6 /lib/mesa/src/gallium/auxiliary/util/u_simple_shaders.c | |
parent | b0244145d5bb49623d58f6b5cab8143ada692b60 (diff) |
Revert to Mesa 13.0.6 to hopefully address rendering issues a handful of
people have reported with xpdf/fvwm on ivy bridge with modesetting driver.
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.c | 120 |
1 files changed, 89 insertions, 31 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 6d29cab92..1220e187e 100644 --- a/lib/mesa/src/gallium/auxiliary/util/u_simple_shaders.c +++ b/lib/mesa/src/gallium/auxiliary/util/u_simple_shaders.c @@ -79,8 +79,8 @@ util_make_vertex_passthrough_shader_with_so(struct pipe_context *pipe, struct ureg_program *ureg; uint i; - ureg = ureg_create( TGSI_PROCESSOR_VERTEX ); - if (ureg == NULL) + ureg = ureg_create( PIPE_SHADER_VERTEX ); + if (!ureg) return NULL; if (window_space) @@ -121,12 +121,13 @@ void *util_make_layered_clear_vertex_shader(struct pipe_context *pipe) "MOV OUT[2], SV[0]\n" "END\n"; struct tgsi_token tokens[1000]; - struct pipe_shader_state state = {tokens}; + struct pipe_shader_state state; - if (!tgsi_text_translate(text, tokens, Elements(tokens))) { + if (!tgsi_text_translate(text, tokens, ARRAY_SIZE(tokens))) { assert(0); return NULL; } + pipe_shader_state_from_tgsi(&state, tokens); return pipe->create_vs_state(pipe, &state); } @@ -149,12 +150,13 @@ void *util_make_layered_clear_helper_vertex_shader(struct pipe_context *pipe) "MOV OUT[2].x, SV[0].xxxx\n" "END\n"; struct tgsi_token tokens[1000]; - struct pipe_shader_state state = {tokens}; + struct pipe_shader_state state; - if (!tgsi_text_translate(text, tokens, Elements(tokens))) { + if (!tgsi_text_translate(text, tokens, ARRAY_SIZE(tokens))) { assert(0); return NULL; } + pipe_shader_state_from_tgsi(&state, tokens); return pipe->create_vs_state(pipe, &state); } @@ -192,12 +194,13 @@ void *util_make_layered_clear_geometry_shader(struct pipe_context *pipe) "EMIT IMM[0].xxxx\n" "END\n"; struct tgsi_token tokens[1000]; - struct pipe_shader_state state = {tokens}; + struct pipe_shader_state state; - if (!tgsi_text_translate(text, tokens, Elements(tokens))) { + if (!tgsi_text_translate(text, tokens, ARRAY_SIZE(tokens))) { assert(0); return NULL; } + pipe_shader_state_from_tgsi(&state, tokens); return pipe->create_gs_state(pipe, &state); } @@ -227,8 +230,8 @@ util_make_fragment_tex_shader_writemask(struct pipe_context *pipe, assert(interp_mode == TGSI_INTERPOLATE_LINEAR || interp_mode == TGSI_INTERPOLATE_PERSPECTIVE); - ureg = ureg_create( TGSI_PROCESSOR_FRAGMENT ); - if (ureg == NULL) + ureg = ureg_create( PIPE_SHADER_FRAGMENT ); + if (!ureg) return NULL; sampler = ureg_DECL_sampler( ureg, 0 ); @@ -297,8 +300,8 @@ util_make_fragment_tex_shader_writedepth(struct pipe_context *pipe, struct ureg_dst out, depth; struct ureg_src imm; - ureg = ureg_create( TGSI_PROCESSOR_FRAGMENT ); - if (ureg == NULL) + ureg = ureg_create( PIPE_SHADER_FRAGMENT ); + if (!ureg) return NULL; sampler = ureg_DECL_sampler( ureg, 0 ); @@ -349,8 +352,8 @@ util_make_fragment_tex_shader_writedepthstencil(struct pipe_context *pipe, struct ureg_dst out, depth, stencil; struct ureg_src imm; - ureg = ureg_create( TGSI_PROCESSOR_FRAGMENT ); - if (ureg == NULL) + ureg = ureg_create( PIPE_SHADER_FRAGMENT ); + if (!ureg) return NULL; depth_sampler = ureg_DECL_sampler( ureg, 0 ); @@ -413,8 +416,8 @@ util_make_fragment_tex_shader_writestencil(struct pipe_context *pipe, struct ureg_dst out, stencil; struct ureg_src imm; - ureg = ureg_create( TGSI_PROCESSOR_FRAGMENT ); - if (ureg == NULL) + ureg = ureg_create( PIPE_SHADER_FRAGMENT ); + if (!ureg) return NULL; stencil_sampler = ureg_DECL_sampler( ureg, 0 ); @@ -471,17 +474,18 @@ util_make_fragment_passthrough_shader(struct pipe_context *pipe, char text[sizeof(shader_templ)+100]; struct tgsi_token tokens[1000]; - struct pipe_shader_state state = {tokens}; + struct pipe_shader_state state; sprintf(text, shader_templ, write_all_cbufs ? "PROPERTY FS_COLOR0_WRITES_ALL_CBUFS 1\n" : "", tgsi_semantic_names[input_semantic], tgsi_interpolate_names[input_interpolate]); - if (!tgsi_text_translate(text, tokens, Elements(tokens))) { + if (!tgsi_text_translate(text, tokens, ARRAY_SIZE(tokens))) { assert(0); return NULL; } + pipe_shader_state_from_tgsi(&state, tokens); #if 0 tgsi_dump(state.tokens, 0); #endif @@ -493,8 +497,8 @@ util_make_fragment_passthrough_shader(struct pipe_context *pipe, void * util_make_empty_fragment_shader(struct pipe_context *pipe) { - struct ureg_program *ureg = ureg_create(TGSI_PROCESSOR_FRAGMENT); - if (ureg == NULL) + struct ureg_program *ureg = ureg_create(PIPE_SHADER_FRAGMENT); + if (!ureg) return NULL; ureg_END(ureg); @@ -517,8 +521,8 @@ util_make_fragment_cloneinput_shader(struct pipe_context *pipe, int num_cbufs, assert(num_cbufs <= PIPE_MAX_COLOR_BUFS); - ureg = ureg_create( TGSI_PROCESSOR_FRAGMENT ); - if (ureg == NULL) + ureg = ureg_create( PIPE_SHADER_FRAGMENT ); + if (!ureg) return NULL; src = ureg_DECL_fs_input( ureg, input_semantic, 0, @@ -558,7 +562,7 @@ util_make_fs_blit_msaa_gen(struct pipe_context *pipe, const char *type = tgsi_texture_names[tgsi_tex]; char text[sizeof(shader_templ)+100]; struct tgsi_token tokens[1000]; - struct pipe_shader_state state = {tokens}; + struct pipe_shader_state state; assert(tgsi_tex == TGSI_TEXTURE_2D_MSAA || tgsi_tex == TGSI_TEXTURE_2D_ARRAY_MSAA); @@ -566,11 +570,12 @@ util_make_fs_blit_msaa_gen(struct pipe_context *pipe, sprintf(text, shader_templ, type, samp_type, output_semantic, output_mask, type); - if (!tgsi_text_translate(text, tokens, Elements(tokens))) { + if (!tgsi_text_translate(text, tokens, ARRAY_SIZE(tokens))) { puts(text); assert(0); return NULL; } + pipe_shader_state_from_tgsi(&state, tokens); #if 0 tgsi_dump(state.tokens, 0); #endif @@ -646,6 +651,7 @@ util_make_fs_blit_msaa_depthstencil(struct pipe_context *pipe, "FRAG\n" "DCL IN[0], GENERIC[0], LINEAR\n" "DCL SAMP[0..1]\n" + "DCL SVIEW[0..1], %s, FLOAT\n" "DCL OUT[0], POSITION\n" "DCL OUT[1], STENCIL\n" "DCL TEMP[0]\n" @@ -658,17 +664,18 @@ util_make_fs_blit_msaa_depthstencil(struct pipe_context *pipe, const char *type = tgsi_texture_names[tgsi_tex]; char text[sizeof(shader_templ)+100]; struct tgsi_token tokens[1000]; - struct pipe_shader_state state = {tokens}; + struct pipe_shader_state state; assert(tgsi_tex == TGSI_TEXTURE_2D_MSAA || tgsi_tex == TGSI_TEXTURE_2D_ARRAY_MSAA); - sprintf(text, shader_templ, type, type); + sprintf(text, shader_templ, type, type, type); - if (!tgsi_text_translate(text, tokens, Elements(tokens))) { + if (!tgsi_text_translate(text, tokens, ARRAY_SIZE(tokens))) { assert(0); return NULL; } + pipe_shader_state_from_tgsi(&state, tokens); #if 0 tgsi_dump(state.tokens, 0); #endif @@ -685,9 +692,9 @@ util_make_fs_msaa_resolve(struct pipe_context *pipe, struct ureg_program *ureg; struct ureg_src sampler, coord; struct ureg_dst out, tmp_sum, tmp_coord, tmp; - int i; + unsigned i; - ureg = ureg_create(TGSI_PROCESSOR_FRAGMENT); + ureg = ureg_create(PIPE_SHADER_FRAGMENT); if (!ureg) return NULL; @@ -746,9 +753,9 @@ util_make_fs_msaa_resolve_bilinear(struct pipe_context *pipe, struct ureg_src sampler, coord; struct ureg_dst out, tmp, top, bottom; struct ureg_dst tmp_coord[4], tmp_sum[4]; - int i, c; + unsigned i, c; - ureg = ureg_create(TGSI_PROCESSOR_FRAGMENT); + ureg = ureg_create(PIPE_SHADER_FRAGMENT); if (!ureg) return NULL; @@ -831,3 +838,54 @@ util_make_fs_msaa_resolve_bilinear(struct pipe_context *pipe, return ureg_create_shader_and_destroy(ureg, pipe); } + +void * +util_make_geometry_passthrough_shader(struct pipe_context *pipe, + uint num_attribs, + const ubyte *semantic_names, + const ubyte *semantic_indexes) +{ + static const unsigned zero[4] = {0, 0, 0, 0}; + + struct ureg_program *ureg; + struct ureg_dst dst[PIPE_MAX_SHADER_OUTPUTS]; + struct ureg_src src[PIPE_MAX_SHADER_INPUTS]; + struct ureg_src imm; + + unsigned i; + + ureg = ureg_create(PIPE_SHADER_GEOMETRY); + if (!ureg) + return NULL; + + ureg_property(ureg, TGSI_PROPERTY_GS_INPUT_PRIM, PIPE_PRIM_POINTS); + ureg_property(ureg, TGSI_PROPERTY_GS_OUTPUT_PRIM, PIPE_PRIM_POINTS); + ureg_property(ureg, TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES, 1); + ureg_property(ureg, TGSI_PROPERTY_GS_INVOCATIONS, 1); + imm = ureg_DECL_immediate_uint(ureg, zero, 4); + + /** + * Loop over all the attribs and declare the corresponding + * declarations in the geometry shader + */ + for (i = 0; i < num_attribs; i++) { + src[i] = ureg_DECL_input(ureg, semantic_names[i], + semantic_indexes[i], 0, 1); + src[i] = ureg_src_dimension(src[i], 0); + dst[i] = ureg_DECL_output(ureg, semantic_names[i], semantic_indexes[i]); + } + + /* MOV dst[i] src[i] */ + for (i = 0; i < num_attribs; i++) { + ureg_MOV(ureg, dst[i], src[i]); + } + + /* EMIT IMM[0] */ + ureg_insn(ureg, TGSI_OPCODE_EMIT, NULL, 0, &imm, 1); + + /* END */ + ureg_END(ureg); + + return ureg_create_shader_and_destroy(ureg, pipe); +} + |