mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 17:50:12 +01:00
softpipe: Use the draw module's poly stipple handling, like llvmpipe.
softpipe was using the draw helper module as a testbed for the draw helper module long ago, but we can just use the finished product. Reviewed-by: Zoltán Böszőrményi <zboszor@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13731>
This commit is contained in:
parent
764d367a62
commit
0b7a0d1a49
7 changed files with 4 additions and 122 deletions
|
|
@ -23,7 +23,6 @@
|
||||||
#include "util/u_inlines.h"
|
#include "util/u_inlines.h"
|
||||||
#include "util/u_math.h"
|
#include "util/u_math.h"
|
||||||
#include "util/u_memory.h"
|
#include "util/u_memory.h"
|
||||||
#include "util/u_pstipple.h"
|
|
||||||
#include "pipe/p_shader_tokens.h"
|
#include "pipe/p_shader_tokens.h"
|
||||||
#include "draw/draw_context.h"
|
#include "draw/draw_context.h"
|
||||||
#include "draw/draw_vertex.h"
|
#include "draw/draw_vertex.h"
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,6 @@
|
||||||
#include "pipe/p_defines.h"
|
#include "pipe/p_defines.h"
|
||||||
#include "util/u_math.h"
|
#include "util/u_math.h"
|
||||||
#include "util/u_memory.h"
|
#include "util/u_memory.h"
|
||||||
#include "util/u_pstipple.h"
|
|
||||||
#include "util/u_inlines.h"
|
#include "util/u_inlines.h"
|
||||||
#include "util/u_upload_mgr.h"
|
#include "util/u_upload_mgr.h"
|
||||||
#include "tgsi/tgsi_exec.h"
|
#include "tgsi/tgsi_exec.h"
|
||||||
|
|
@ -60,14 +59,6 @@ softpipe_destroy( struct pipe_context *pipe )
|
||||||
struct softpipe_context *softpipe = softpipe_context( pipe );
|
struct softpipe_context *softpipe = softpipe_context( pipe );
|
||||||
uint i, sh;
|
uint i, sh;
|
||||||
|
|
||||||
#if DO_PSTIPPLE_IN_HELPER_MODULE
|
|
||||||
if (softpipe->pstipple.sampler)
|
|
||||||
pipe->delete_sampler_state(pipe, softpipe->pstipple.sampler);
|
|
||||||
|
|
||||||
pipe_resource_reference(&softpipe->pstipple.texture, NULL);
|
|
||||||
pipe_sampler_view_reference(&softpipe->pstipple.sampler_view, NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (softpipe->blitter) {
|
if (softpipe->blitter) {
|
||||||
util_blitter_destroy(softpipe->blitter);
|
util_blitter_destroy(softpipe->blitter);
|
||||||
}
|
}
|
||||||
|
|
@ -344,20 +335,13 @@ softpipe_create_context(struct pipe_screen *screen,
|
||||||
draw_install_aaline_stage(softpipe->draw, &softpipe->pipe);
|
draw_install_aaline_stage(softpipe->draw, &softpipe->pipe);
|
||||||
draw_install_aapoint_stage(softpipe->draw, &softpipe->pipe);
|
draw_install_aapoint_stage(softpipe->draw, &softpipe->pipe);
|
||||||
|
|
||||||
/* Do polygon stipple w/ texture map + frag prog? */
|
/* Do polygon stipple w/ texture map + frag prog. */
|
||||||
#if DO_PSTIPPLE_IN_DRAW_MODULE
|
|
||||||
draw_install_pstipple_stage(softpipe->draw, &softpipe->pipe);
|
draw_install_pstipple_stage(softpipe->draw, &softpipe->pipe);
|
||||||
#endif
|
|
||||||
|
|
||||||
draw_wide_point_sprites(softpipe->draw, TRUE);
|
draw_wide_point_sprites(softpipe->draw, TRUE);
|
||||||
|
|
||||||
sp_init_surface_functions(softpipe);
|
sp_init_surface_functions(softpipe);
|
||||||
|
|
||||||
#if DO_PSTIPPLE_IN_HELPER_MODULE
|
|
||||||
/* create the polygon stipple sampler */
|
|
||||||
softpipe->pstipple.sampler = util_pstipple_create_sampler(&softpipe->pipe);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return &softpipe->pipe;
|
return &softpipe->pipe;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
|
|
||||||
|
|
@ -40,13 +40,6 @@
|
||||||
#include "sp_setup.h"
|
#include "sp_setup.h"
|
||||||
|
|
||||||
|
|
||||||
/** Do polygon stipple in the draw module? */
|
|
||||||
#define DO_PSTIPPLE_IN_DRAW_MODULE 0
|
|
||||||
|
|
||||||
/** Do polygon stipple with the util module? */
|
|
||||||
#define DO_PSTIPPLE_IN_HELPER_MODULE 1
|
|
||||||
|
|
||||||
|
|
||||||
struct softpipe_vbuf_render;
|
struct softpipe_vbuf_render;
|
||||||
struct draw_context;
|
struct draw_context;
|
||||||
struct draw_stage;
|
struct draw_stage;
|
||||||
|
|
@ -80,7 +73,6 @@ struct softpipe_context {
|
||||||
struct pipe_clip_state clip;
|
struct pipe_clip_state clip;
|
||||||
struct pipe_resource *constants[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS];
|
struct pipe_resource *constants[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS];
|
||||||
struct pipe_framebuffer_state framebuffer;
|
struct pipe_framebuffer_state framebuffer;
|
||||||
struct pipe_poly_stipple poly_stipple;
|
|
||||||
struct pipe_scissor_state scissors[PIPE_MAX_VIEWPORTS];
|
struct pipe_scissor_state scissors[PIPE_MAX_VIEWPORTS];
|
||||||
struct pipe_sampler_view *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_SAMPLER_VIEWS];
|
struct pipe_sampler_view *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_SAMPLER_VIEWS];
|
||||||
|
|
||||||
|
|
@ -153,13 +145,6 @@ struct softpipe_context {
|
||||||
enum pipe_render_cond_flag render_cond_mode;
|
enum pipe_render_cond_flag render_cond_mode;
|
||||||
bool render_cond_cond;
|
bool render_cond_cond;
|
||||||
|
|
||||||
/** Polygon stipple items */
|
|
||||||
struct {
|
|
||||||
struct pipe_resource *texture;
|
|
||||||
struct pipe_sampler_state *sampler;
|
|
||||||
struct pipe_sampler_view *sampler_view;
|
|
||||||
} pstipple;
|
|
||||||
|
|
||||||
/** Software quad rendering pipeline */
|
/** Software quad rendering pipeline */
|
||||||
struct {
|
struct {
|
||||||
struct quad_stage *shade;
|
struct quad_stage *shade;
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@
|
||||||
#define SP_NEW_BLEND 0x8
|
#define SP_NEW_BLEND 0x8
|
||||||
#define SP_NEW_CLIP 0x10
|
#define SP_NEW_CLIP 0x10
|
||||||
#define SP_NEW_SCISSOR 0x20
|
#define SP_NEW_SCISSOR 0x20
|
||||||
#define SP_NEW_STIPPLE 0x40
|
|
||||||
#define SP_NEW_FRAMEBUFFER 0x80
|
#define SP_NEW_FRAMEBUFFER 0x80
|
||||||
#define SP_NEW_DEPTH_STENCIL_ALPHA 0x100
|
#define SP_NEW_DEPTH_STENCIL_ALPHA 0x100
|
||||||
#define SP_NEW_CONSTANTS 0x200
|
#define SP_NEW_CONSTANTS 0x200
|
||||||
|
|
@ -64,7 +64,6 @@ struct vertex_info;
|
||||||
|
|
||||||
struct sp_fragment_shader_variant_key
|
struct sp_fragment_shader_variant_key
|
||||||
{
|
{
|
||||||
boolean polygon_stipple;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -74,8 +73,6 @@ struct sp_fragment_shader_variant
|
||||||
struct sp_fragment_shader_variant_key key;
|
struct sp_fragment_shader_variant_key key;
|
||||||
struct tgsi_shader_info info;
|
struct tgsi_shader_info info;
|
||||||
|
|
||||||
unsigned stipple_sampler_unit;
|
|
||||||
|
|
||||||
/* See comments about this elsewhere */
|
/* See comments about this elsewhere */
|
||||||
#if 0
|
#if 0
|
||||||
struct draw_fragment_shader *draw_shader;
|
struct draw_fragment_shader *draw_shader;
|
||||||
|
|
|
||||||
|
|
@ -84,12 +84,10 @@ static void
|
||||||
softpipe_set_polygon_stipple(struct pipe_context *pipe,
|
softpipe_set_polygon_stipple(struct pipe_context *pipe,
|
||||||
const struct pipe_poly_stipple *stipple)
|
const struct pipe_poly_stipple *stipple)
|
||||||
{
|
{
|
||||||
|
/* Actual stippling handled by draw module. */
|
||||||
struct softpipe_context *softpipe = softpipe_context(pipe);
|
struct softpipe_context *softpipe = softpipe_context(pipe);
|
||||||
|
|
||||||
draw_flush(softpipe->draw);
|
draw_flush(softpipe->draw);
|
||||||
|
|
||||||
softpipe->poly_stipple = *stipple; /* struct copy */
|
|
||||||
softpipe->dirty |= SP_NEW_STIPPLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@
|
||||||
#include "util/u_inlines.h"
|
#include "util/u_inlines.h"
|
||||||
#include "util/u_math.h"
|
#include "util/u_math.h"
|
||||||
#include "util/u_memory.h"
|
#include "util/u_memory.h"
|
||||||
#include "util/u_pstipple.h"
|
|
||||||
#include "pipe/p_shader_tokens.h"
|
#include "pipe/p_shader_tokens.h"
|
||||||
#include "draw/draw_context.h"
|
#include "draw/draw_context.h"
|
||||||
#include "draw/draw_vertex.h"
|
#include "draw/draw_vertex.h"
|
||||||
|
|
@ -338,9 +337,6 @@ update_fragment_shader(struct softpipe_context *softpipe, unsigned prim)
|
||||||
|
|
||||||
memset(&key, 0, sizeof(key));
|
memset(&key, 0, sizeof(key));
|
||||||
|
|
||||||
if (prim == PIPE_PRIM_TRIANGLES)
|
|
||||||
key.polygon_stipple = softpipe->rasterizer->poly_stipple_enable;
|
|
||||||
|
|
||||||
if (softpipe->fs) {
|
if (softpipe->fs) {
|
||||||
softpipe->fs_variant = softpipe_find_fs_variant(softpipe,
|
softpipe->fs_variant = softpipe_find_fs_variant(softpipe,
|
||||||
softpipe->fs, &key);
|
softpipe->fs, &key);
|
||||||
|
|
@ -377,56 +373,6 @@ update_fragment_shader(struct softpipe_context *softpipe, unsigned prim)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This should be called when the polygon stipple pattern changes.
|
|
||||||
* We create a new texture from the stipple pattern and create a new
|
|
||||||
* sampler view.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
update_polygon_stipple_pattern(struct softpipe_context *softpipe)
|
|
||||||
{
|
|
||||||
struct pipe_resource *tex;
|
|
||||||
struct pipe_sampler_view *view;
|
|
||||||
|
|
||||||
tex = util_pstipple_create_stipple_texture(&softpipe->pipe,
|
|
||||||
softpipe->poly_stipple.stipple);
|
|
||||||
pipe_resource_reference(&softpipe->pstipple.texture, tex);
|
|
||||||
pipe_resource_reference(&tex, NULL);
|
|
||||||
|
|
||||||
view = util_pstipple_create_sampler_view(&softpipe->pipe,
|
|
||||||
softpipe->pstipple.texture);
|
|
||||||
pipe_sampler_view_reference(&softpipe->pstipple.sampler_view, view);
|
|
||||||
pipe_sampler_view_reference(&view, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Should be called when polygon stipple is enabled/disabled or when
|
|
||||||
* the fragment shader changes.
|
|
||||||
* We add/update the fragment sampler and sampler views to sample from
|
|
||||||
* the polygon stipple texture. The texture unit that we use depends on
|
|
||||||
* the fragment shader (we need to use a unit not otherwise used by the
|
|
||||||
* shader).
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
update_polygon_stipple_enable(struct softpipe_context *softpipe, unsigned prim)
|
|
||||||
{
|
|
||||||
if (prim == PIPE_PRIM_TRIANGLES &&
|
|
||||||
softpipe->fs_variant->key.polygon_stipple) {
|
|
||||||
const unsigned unit = softpipe->fs_variant->stipple_sampler_unit;
|
|
||||||
|
|
||||||
/* sampler state */
|
|
||||||
softpipe->samplers[PIPE_SHADER_FRAGMENT][unit] = softpipe->pstipple.sampler;
|
|
||||||
|
|
||||||
/* sampler view state */
|
|
||||||
softpipe_set_sampler_views(&softpipe->pipe, PIPE_SHADER_FRAGMENT,
|
|
||||||
unit, 1, 0, false, &softpipe->pstipple.sampler_view);
|
|
||||||
|
|
||||||
softpipe->dirty |= SP_NEW_SAMPLER;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Hopefully this will remain quite simple, otherwise need to pull in
|
/* Hopefully this will remain quite simple, otherwise need to pull in
|
||||||
* something like the gallium frontend mechanism.
|
* something like the gallium frontend mechanism.
|
||||||
*/
|
*/
|
||||||
|
|
@ -442,23 +388,10 @@ softpipe_update_derived(struct softpipe_context *softpipe, unsigned prim)
|
||||||
softpipe->dirty |= SP_NEW_TEXTURE;
|
softpipe->dirty |= SP_NEW_TEXTURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DO_PSTIPPLE_IN_HELPER_MODULE
|
|
||||||
if (softpipe->dirty & SP_NEW_STIPPLE)
|
|
||||||
/* before updating samplers! */
|
|
||||||
update_polygon_stipple_pattern(softpipe);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (softpipe->dirty & (SP_NEW_RASTERIZER |
|
if (softpipe->dirty & (SP_NEW_RASTERIZER |
|
||||||
SP_NEW_FS))
|
SP_NEW_FS))
|
||||||
update_fragment_shader(softpipe, prim);
|
update_fragment_shader(softpipe, prim);
|
||||||
|
|
||||||
#if DO_PSTIPPLE_IN_HELPER_MODULE
|
|
||||||
if (softpipe->dirty & (SP_NEW_RASTERIZER |
|
|
||||||
SP_NEW_STIPPLE |
|
|
||||||
SP_NEW_FS))
|
|
||||||
update_polygon_stipple_enable(softpipe, prim);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* TODO: this looks suboptimal */
|
/* TODO: this looks suboptimal */
|
||||||
if (softpipe->dirty & (SP_NEW_SAMPLER |
|
if (softpipe->dirty & (SP_NEW_SAMPLER |
|
||||||
SP_NEW_TEXTURE |
|
SP_NEW_TEXTURE |
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,6 @@
|
||||||
#include "util/ralloc.h"
|
#include "util/ralloc.h"
|
||||||
#include "util/u_memory.h"
|
#include "util/u_memory.h"
|
||||||
#include "util/u_inlines.h"
|
#include "util/u_inlines.h"
|
||||||
#include "util/u_pstipple.h"
|
|
||||||
#include "draw/draw_context.h"
|
#include "draw/draw_context.h"
|
||||||
#include "draw/draw_vs.h"
|
#include "draw/draw_vs.h"
|
||||||
#include "draw/draw_gs.h"
|
#include "draw/draw_gs.h"
|
||||||
|
|
@ -65,20 +64,7 @@ create_fs_variant(struct softpipe_context *softpipe,
|
||||||
if (var) {
|
if (var) {
|
||||||
var->key = *key;
|
var->key = *key;
|
||||||
|
|
||||||
#if DO_PSTIPPLE_IN_HELPER_MODULE
|
var->tokens = tgsi_dup_tokens(curfs->tokens);
|
||||||
if (key->polygon_stipple) {
|
|
||||||
/* get new shader that implements polygon stippling */
|
|
||||||
var->tokens =
|
|
||||||
util_pstipple_create_fragment_shader(curfs->tokens,
|
|
||||||
&var->stipple_sampler_unit, 0,
|
|
||||||
TGSI_FILE_INPUT);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
var->tokens = tgsi_dup_tokens(curfs->tokens);
|
|
||||||
var->stipple_sampler_unit = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
tgsi_scan_shader(var->tokens, &var->info);
|
tgsi_scan_shader(var->tokens, &var->info);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue