gallium: streamline viewport/raster/shader state for clearing with quads
Move init of these items to new st_init_clear().
This commit is contained in:
@@ -55,6 +55,42 @@
|
|||||||
#include "cso_cache/cso_context.h"
|
#include "cso_cache/cso_context.h"
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
st_init_clear(struct st_context *st)
|
||||||
|
{
|
||||||
|
struct pipe_context *pipe = st->pipe;
|
||||||
|
|
||||||
|
/* rasterizer state: bypass clipping */
|
||||||
|
memset(&st->clear.raster, 0, sizeof(st->clear.raster));
|
||||||
|
st->clear.raster.bypass_clipping = 1;
|
||||||
|
|
||||||
|
/* viewport state: identity since we're drawing in window coords */
|
||||||
|
st->clear.viewport.scale[0] = 1.0;
|
||||||
|
st->clear.viewport.scale[1] = 1.0;
|
||||||
|
st->clear.viewport.scale[2] = 1.0;
|
||||||
|
st->clear.viewport.scale[3] = 1.0;
|
||||||
|
st->clear.viewport.translate[0] = 0.0;
|
||||||
|
st->clear.viewport.translate[1] = 0.0;
|
||||||
|
st->clear.viewport.translate[2] = 0.0;
|
||||||
|
st->clear.viewport.translate[3] = 0.0;
|
||||||
|
|
||||||
|
/* fragment shader state: color pass-through program */
|
||||||
|
st->clear.fs =
|
||||||
|
util_make_fragment_passthrough_shader(pipe, &st->clear.frag_shader);
|
||||||
|
|
||||||
|
/* vertex shader state: color/position pass-through */
|
||||||
|
{
|
||||||
|
const uint semantic_names[] = { TGSI_SEMANTIC_POSITION,
|
||||||
|
TGSI_SEMANTIC_COLOR };
|
||||||
|
const uint semantic_indexes[] = { 0, 0 };
|
||||||
|
st->clear.vs = util_make_vertex_passthrough_shader(pipe, 2,
|
||||||
|
semantic_names,
|
||||||
|
semantic_indexes,
|
||||||
|
&st->clear.vert_shader);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
st_destroy_clear(struct st_context *st)
|
st_destroy_clear(struct st_context *st)
|
||||||
{
|
{
|
||||||
@@ -233,47 +269,12 @@ clear_with_quad(GLcontext *ctx,
|
|||||||
cso_set_depth_stencil_alpha(st->cso_context, &depth_stencil);
|
cso_set_depth_stencil_alpha(st->cso_context, &depth_stencil);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* rasterizer state: bypass clipping */
|
cso_set_rasterizer(st->cso_context, &st->clear.raster);
|
||||||
{
|
cso_set_viewport(st->cso_context, &st->clear.viewport);
|
||||||
struct pipe_rasterizer_state raster;
|
|
||||||
memset(&raster, 0, sizeof(raster));
|
|
||||||
raster.bypass_clipping = 1;
|
|
||||||
cso_set_rasterizer(st->cso_context, &raster);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* fragment shader state: color pass-through program */
|
|
||||||
if (!st->clear.fs) {
|
|
||||||
st->clear.fs = util_make_fragment_passthrough_shader(pipe, &st->clear.frag_shader);
|
|
||||||
}
|
|
||||||
pipe->bind_fs_state(pipe, st->clear.fs);
|
pipe->bind_fs_state(pipe, st->clear.fs);
|
||||||
|
|
||||||
|
|
||||||
/* vertex shader state: color/position pass-through */
|
|
||||||
if (!st->clear.vs) {
|
|
||||||
const uint semantic_names[] = { TGSI_SEMANTIC_POSITION,
|
|
||||||
TGSI_SEMANTIC_COLOR };
|
|
||||||
const uint semantic_indexes[] = { 0, 0 };
|
|
||||||
st->clear.vs = util_make_vertex_passthrough_shader(pipe, 2,
|
|
||||||
semantic_names,
|
|
||||||
semantic_indexes,
|
|
||||||
&st->clear.vert_shader);
|
|
||||||
}
|
|
||||||
pipe->bind_vs_state(pipe, st->clear.vs);
|
pipe->bind_vs_state(pipe, st->clear.vs);
|
||||||
|
|
||||||
/* viewport state: identity since we're drawing in window coords */
|
|
||||||
{
|
|
||||||
struct pipe_viewport_state vp;
|
|
||||||
vp.scale[0] = 1.0;
|
|
||||||
vp.scale[1] = 1.0;
|
|
||||||
vp.scale[2] = 1.0;
|
|
||||||
vp.scale[3] = 1.0;
|
|
||||||
vp.translate[0] = 0.0;
|
|
||||||
vp.translate[1] = 0.0;
|
|
||||||
vp.translate[2] = 0.0;
|
|
||||||
vp.translate[3] = 0.0;
|
|
||||||
cso_set_viewport(st->cso_context, &vp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* draw quad matching scissor rect (XXX verify coord round-off) */
|
/* draw quad matching scissor rect (XXX verify coord round-off) */
|
||||||
draw_quad(ctx, x0, y0, x1, y1, ctx->Depth.Clear, ctx->Color.ClearColor);
|
draw_quad(ctx, x0, y0, x1, y1, ctx->Depth.Clear, ctx->Color.ClearColor);
|
||||||
|
|
||||||
|
@@ -30,6 +30,10 @@
|
|||||||
#define ST_CB_CLEAR_H
|
#define ST_CB_CLEAR_H
|
||||||
|
|
||||||
|
|
||||||
|
extern void
|
||||||
|
st_init_clear(struct st_context *st);
|
||||||
|
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
st_destroy_clear(struct st_context *st);
|
st_destroy_clear(struct st_context *st);
|
||||||
|
|
||||||
|
@@ -110,6 +110,7 @@ st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe )
|
|||||||
|
|
||||||
st_init_atoms( st );
|
st_init_atoms( st );
|
||||||
st_init_bitmap(st);
|
st_init_bitmap(st);
|
||||||
|
st_init_clear(st);
|
||||||
st_init_draw( st );
|
st_init_draw( st );
|
||||||
st_init_generate_mipmap(st);
|
st_init_generate_mipmap(st);
|
||||||
st_init_blit(st);
|
st_init_blit(st);
|
||||||
|
@@ -161,6 +161,8 @@ struct st_context
|
|||||||
struct {
|
struct {
|
||||||
struct pipe_shader_state vert_shader;
|
struct pipe_shader_state vert_shader;
|
||||||
struct pipe_shader_state frag_shader;
|
struct pipe_shader_state frag_shader;
|
||||||
|
struct pipe_rasterizer_state raster;
|
||||||
|
struct pipe_viewport_state viewport;
|
||||||
void *vs;
|
void *vs;
|
||||||
void *fs;
|
void *fs;
|
||||||
float vertices[4][2][4]; /**< vertex pos + color */
|
float vertices[4][2][4]; /**< vertex pos + color */
|
||||||
|
Reference in New Issue
Block a user