Use the code in cso_context.c rather than st_cache.c.
Basically, binding of state objects now goes through the CSO module.
But Vertex/fragment shaders go through pipe->bind_fs/vs_state() since they're
not cached by the CSO module at this time.
Also, update softpipe driver to handle NULL state objects in various places.
This happens during context destruction. May need to update other drivers...
/* save current */
aaline->fs = aafs;
/* pass-through */
- aaline->driver_bind_fs_state(aaline->pipe, aafs->driver_fs);
+ aaline->driver_bind_fs_state(aaline->pipe,
+ (aafs ? aafs->driver_fs : NULL));
}
/* save current */
aapoint->fs = aafs;
/* pass-through */
- aapoint->driver_bind_fs_state(aapoint->pipe, aafs->driver_fs);
+ aapoint->driver_bind_fs_state(aapoint->pipe,
+ (aafs ? aafs->driver_fs : NULL));
}
/* save current */
pstip->fs = aafs;
/* pass-through */
- pstip->driver_bind_fs_state(pstip->pipe, aafs->driver_fs);
+ pstip->driver_bind_fs_state(pstip->pipe,
+ (aafs ? aafs->driver_fs : NULL));
}
softpipe->vs = (const struct sp_vertex_shader *)vs;
- draw_bind_vertex_shader(softpipe->draw, softpipe->vs->draw_data);
+ draw_bind_vertex_shader(softpipe->draw,
+ (softpipe->vs ? softpipe->vs->draw_data : NULL));
softpipe->dirty |= SP_NEW_VS;
}
state_tracker/st_cb_readpixels.c \
state_tracker/st_cb_strings.c \
state_tracker/st_cb_texture.c \
- state_tracker/st_cache.c \
state_tracker/st_context.c \
state_tracker/st_debug.c \
state_tracker/st_draw.c \
#include "st_context.h"
-#include "st_cache.h"
#include "st_atom.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
+#include "cso_cache/cso_context.h"
/**
static void
update_blend( struct st_context *st )
{
- struct pipe_blend_state blend;
- const struct cso_blend *cso;
+ struct pipe_blend_state *blend = &st->state.blend;
- memset(&blend, 0, sizeof(blend));
+ memset(blend, 0, sizeof(*blend));
if (st->ctx->Color.ColorLogicOpEnabled ||
(st->ctx->Color.BlendEnabled &&
st->ctx->Color.BlendEquationRGB == GL_LOGIC_OP)) {
/* logicop enabled */
- blend.logicop_enable = 1;
- blend.logicop_func = translate_logicop(st->ctx->Color.LogicOp);
+ blend->logicop_enable = 1;
+ blend->logicop_func = translate_logicop(st->ctx->Color.LogicOp);
}
else if (st->ctx->Color.BlendEnabled) {
/* blending enabled */
- blend.blend_enable = 1;
+ blend->blend_enable = 1;
- blend.rgb_func = translate_blend(st->ctx->Color.BlendEquationRGB);
+ blend->rgb_func = translate_blend(st->ctx->Color.BlendEquationRGB);
if (st->ctx->Color.BlendEquationRGB == GL_MIN ||
st->ctx->Color.BlendEquationRGB == GL_MAX) {
/* Min/max are special */
- blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE;
- blend.rgb_dst_factor = PIPE_BLENDFACTOR_ONE;
+ blend->rgb_src_factor = PIPE_BLENDFACTOR_ONE;
+ blend->rgb_dst_factor = PIPE_BLENDFACTOR_ONE;
}
else {
- blend.rgb_src_factor = translate_blend(st->ctx->Color.BlendSrcRGB);
- blend.rgb_dst_factor = translate_blend(st->ctx->Color.BlendDstRGB);
+ blend->rgb_src_factor = translate_blend(st->ctx->Color.BlendSrcRGB);
+ blend->rgb_dst_factor = translate_blend(st->ctx->Color.BlendDstRGB);
}
- blend.alpha_func = translate_blend(st->ctx->Color.BlendEquationA);
+ blend->alpha_func = translate_blend(st->ctx->Color.BlendEquationA);
if (st->ctx->Color.BlendEquationA == GL_MIN ||
st->ctx->Color.BlendEquationA == GL_MAX) {
/* Min/max are special */
- blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE;
- blend.alpha_dst_factor = PIPE_BLENDFACTOR_ONE;
+ blend->alpha_src_factor = PIPE_BLENDFACTOR_ONE;
+ blend->alpha_dst_factor = PIPE_BLENDFACTOR_ONE;
}
else {
- blend.alpha_src_factor = translate_blend(st->ctx->Color.BlendSrcA);
- blend.alpha_dst_factor = translate_blend(st->ctx->Color.BlendDstA);
+ blend->alpha_src_factor = translate_blend(st->ctx->Color.BlendSrcA);
+ blend->alpha_dst_factor = translate_blend(st->ctx->Color.BlendDstA);
}
}
else {
/* Colormask - maybe reverse these bits? */
if (st->ctx->Color.ColorMask[0])
- blend.colormask |= PIPE_MASK_R;
+ blend->colormask |= PIPE_MASK_R;
if (st->ctx->Color.ColorMask[1])
- blend.colormask |= PIPE_MASK_G;
+ blend->colormask |= PIPE_MASK_G;
if (st->ctx->Color.ColorMask[2])
- blend.colormask |= PIPE_MASK_B;
+ blend->colormask |= PIPE_MASK_B;
if (st->ctx->Color.ColorMask[3])
- blend.colormask |= PIPE_MASK_A;
+ blend->colormask |= PIPE_MASK_A;
if (st->ctx->Color.DitherFlag)
- blend.dither = 1;
+ blend->dither = 1;
- cso = st_cached_blend_state(st, &blend);
-
- if (st->state.blend != cso) {
- /* state has changed */
- st->state.blend = cso;
- /* bind new state */
- st->pipe->bind_blend_state(st->pipe, cso->data);
- }
+ cso_set_blend(st->cso_context, blend);
if (memcmp(st->ctx->Color.BlendColor, &st->state.blend_color, 4 * sizeof(GLfloat)) != 0) {
/* state has changed */
#include "st_context.h"
-#include "st_cache.h"
#include "st_atom.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
+#include "cso_cache/cso_context.h"
/**
static void
update_depth_stencil_alpha(struct st_context *st)
{
- struct pipe_depth_stencil_alpha_state depth_stencil;
- const struct cso_depth_stencil_alpha *cso;
+ struct pipe_depth_stencil_alpha_state *dsa = &st->state.depth_stencil;
- memset(&depth_stencil, 0, sizeof(depth_stencil));
+ memset(dsa, 0, sizeof(*dsa));
- depth_stencil.depth.enabled = st->ctx->Depth.Test;
- depth_stencil.depth.writemask = st->ctx->Depth.Mask;
- depth_stencil.depth.func = st_compare_func_to_pipe(st->ctx->Depth.Func);
+ dsa->depth.enabled = st->ctx->Depth.Test;
+ dsa->depth.writemask = st->ctx->Depth.Mask;
+ dsa->depth.func = st_compare_func_to_pipe(st->ctx->Depth.Func);
if (st->ctx->Query.CurrentOcclusionObject &&
st->ctx->Query.CurrentOcclusionObject->Active)
- depth_stencil.depth.occlusion_count = 1;
+ dsa->depth.occlusion_count = 1;
if (st->ctx->Stencil.Enabled) {
- depth_stencil.stencil[0].enabled = 1;
- depth_stencil.stencil[0].func = st_compare_func_to_pipe(st->ctx->Stencil.Function[0]);
- depth_stencil.stencil[0].fail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.FailFunc[0]);
- depth_stencil.stencil[0].zfail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZFailFunc[0]);
- depth_stencil.stencil[0].zpass_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZPassFunc[0]);
- depth_stencil.stencil[0].ref_value = st->ctx->Stencil.Ref[0] & 0xff;
- depth_stencil.stencil[0].value_mask = st->ctx->Stencil.ValueMask[0] & 0xff;
- depth_stencil.stencil[0].write_mask = st->ctx->Stencil.WriteMask[0] & 0xff;
+ dsa->stencil[0].enabled = 1;
+ dsa->stencil[0].func = st_compare_func_to_pipe(st->ctx->Stencil.Function[0]);
+ dsa->stencil[0].fail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.FailFunc[0]);
+ dsa->stencil[0].zfail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZFailFunc[0]);
+ dsa->stencil[0].zpass_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZPassFunc[0]);
+ dsa->stencil[0].ref_value = st->ctx->Stencil.Ref[0] & 0xff;
+ dsa->stencil[0].value_mask = st->ctx->Stencil.ValueMask[0] & 0xff;
+ dsa->stencil[0].write_mask = st->ctx->Stencil.WriteMask[0] & 0xff;
if (st->ctx->Stencil.TestTwoSide) {
- depth_stencil.stencil[1].enabled = 1;
- depth_stencil.stencil[1].func = st_compare_func_to_pipe(st->ctx->Stencil.Function[1]);
- depth_stencil.stencil[1].fail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.FailFunc[1]);
- depth_stencil.stencil[1].zfail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZFailFunc[1]);
- depth_stencil.stencil[1].zpass_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZPassFunc[1]);
- depth_stencil.stencil[1].ref_value = st->ctx->Stencil.Ref[1] & 0xff;
- depth_stencil.stencil[1].value_mask = st->ctx->Stencil.ValueMask[1] & 0xff;
- depth_stencil.stencil[1].write_mask = st->ctx->Stencil.WriteMask[1] & 0xff;
+ dsa->stencil[1].enabled = 1;
+ dsa->stencil[1].func = st_compare_func_to_pipe(st->ctx->Stencil.Function[1]);
+ dsa->stencil[1].fail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.FailFunc[1]);
+ dsa->stencil[1].zfail_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZFailFunc[1]);
+ dsa->stencil[1].zpass_op = gl_stencil_op_to_pipe(st->ctx->Stencil.ZPassFunc[1]);
+ dsa->stencil[1].ref_value = st->ctx->Stencil.Ref[1] & 0xff;
+ dsa->stencil[1].value_mask = st->ctx->Stencil.ValueMask[1] & 0xff;
+ dsa->stencil[1].write_mask = st->ctx->Stencil.WriteMask[1] & 0xff;
}
}
if (st->ctx->Color.AlphaEnabled) {
- depth_stencil.alpha.enabled = 1;
- depth_stencil.alpha.func = st_compare_func_to_pipe(st->ctx->Color.AlphaFunc);
- depth_stencil.alpha.ref = st->ctx->Color.AlphaRef;
+ dsa->alpha.enabled = 1;
+ dsa->alpha.func = st_compare_func_to_pipe(st->ctx->Color.AlphaFunc);
+ dsa->alpha.ref = st->ctx->Color.AlphaRef;
}
- cso = st_cached_depth_stencil_alpha_state(st, &depth_stencil);
- if (st->state.depth_stencil != cso) {
- /* state has changed */
- st->state.depth_stencil = cso;
- st->pipe->bind_depth_stencil_alpha_state(st->pipe, cso->data); /* bind new state */
- }
+ cso_set_depth_stencil_alpha(st->cso_context, dsa);
}
#include "main/macros.h"
#include "st_context.h"
-#include "st_cache.h"
+#include "st_atom.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
-#include "st_atom.h"
+#include "cso_cache/cso_context.h"
+
static GLuint translate_fill( GLenum mode )
{
static void update_raster_state( struct st_context *st )
{
GLcontext *ctx = st->ctx;
- struct pipe_rasterizer_state raster;
- const struct cso_rasterizer *cso;
+ struct pipe_rasterizer_state *raster = &st->state.rasterizer;
const struct gl_vertex_program *vertProg = ctx->VertexProgram._Current;
uint i;
- memset(&raster, 0, sizeof(raster));
+ memset(raster, 0, sizeof(*raster));
- raster.origin_lower_left = 1; /* Always true for OpenGL */
+ raster->origin_lower_left = 1; /* Always true for OpenGL */
/* _NEW_POLYGON, _NEW_BUFFERS
*/
{
if (ctx->Polygon.FrontFace == GL_CCW)
- raster.front_winding = PIPE_WINDING_CCW;
+ raster->front_winding = PIPE_WINDING_CCW;
else
- raster.front_winding = PIPE_WINDING_CW;
+ raster->front_winding = PIPE_WINDING_CW;
/* XXX
* I think the intention here is that user-created framebuffer objects
* But this is an implementation/driver-specific artifact - remove...
*/
if (ctx->DrawBuffer && ctx->DrawBuffer->Name != 0)
- raster.front_winding ^= PIPE_WINDING_BOTH;
+ raster->front_winding ^= PIPE_WINDING_BOTH;
}
/* _NEW_LIGHT
*/
if (ctx->Light.ShadeModel == GL_FLAT)
- raster.flatshade = 1;
+ raster->flatshade = 1;
/* _NEW_LIGHT | _NEW_PROGRAM
*
if (ctx->VertexProgram._Current) {
if (ctx->VertexProgram._Enabled) {
/* user-defined program */
- raster.light_twoside = ctx->VertexProgram.TwoSideEnabled;
+ raster->light_twoside = ctx->VertexProgram.TwoSideEnabled;
}
else {
/* TNL-generated program */
- raster.light_twoside = ctx->Light.Enabled && ctx->Light.Model.TwoSide;
+ raster->light_twoside = ctx->Light.Enabled && ctx->Light.Model.TwoSide;
}
}
else if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) {
- raster.light_twoside = 1;
+ raster->light_twoside = 1;
}
/* _NEW_POLYGON
*/
if (ctx->Polygon.CullFlag) {
if (ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) {
- raster.cull_mode = PIPE_WINDING_BOTH;
+ raster->cull_mode = PIPE_WINDING_BOTH;
}
else if (ctx->Polygon.CullFaceMode == GL_FRONT) {
- raster.cull_mode = raster.front_winding;
+ raster->cull_mode = raster->front_winding;
}
else {
- raster.cull_mode = raster.front_winding ^ PIPE_WINDING_BOTH;
+ raster->cull_mode = raster->front_winding ^ PIPE_WINDING_BOTH;
}
}
GLuint fill_front = translate_fill( ctx->Polygon.FrontMode );
GLuint fill_back = translate_fill( ctx->Polygon.BackMode );
- if (raster.front_winding == PIPE_WINDING_CW) {
- raster.fill_cw = fill_front;
- raster.fill_ccw = fill_back;
+ if (raster->front_winding == PIPE_WINDING_CW) {
+ raster->fill_cw = fill_front;
+ raster->fill_ccw = fill_back;
}
else {
- raster.fill_cw = fill_back;
- raster.fill_ccw = fill_front;
+ raster->fill_cw = fill_back;
+ raster->fill_ccw = fill_front;
}
/* Simplify when culling is active:
*/
- if (raster.cull_mode & PIPE_WINDING_CW) {
- raster.fill_cw = raster.fill_ccw;
+ if (raster->cull_mode & PIPE_WINDING_CW) {
+ raster->fill_cw = raster->fill_ccw;
}
- if (raster.cull_mode & PIPE_WINDING_CCW) {
- raster.fill_ccw = raster.fill_cw;
+ if (raster->cull_mode & PIPE_WINDING_CCW) {
+ raster->fill_ccw = raster->fill_cw;
}
}
*/
if (ctx->Polygon.OffsetUnits != 0.0 ||
ctx->Polygon.OffsetFactor != 0.0) {
- raster.offset_cw = get_offset_flag( raster.fill_cw, &ctx->Polygon );
- raster.offset_ccw = get_offset_flag( raster.fill_ccw, &ctx->Polygon );
- raster.offset_units = ctx->Polygon.OffsetUnits;
- raster.offset_scale = ctx->Polygon.OffsetFactor;
+ raster->offset_cw = get_offset_flag( raster->fill_cw, &ctx->Polygon );
+ raster->offset_ccw = get_offset_flag( raster->fill_ccw, &ctx->Polygon );
+ raster->offset_units = ctx->Polygon.OffsetUnits;
+ raster->offset_scale = ctx->Polygon.OffsetFactor;
}
if (ctx->Polygon.SmoothFlag)
- raster.poly_smooth = 1;
+ raster->poly_smooth = 1;
if (ctx->Polygon.StippleFlag)
- raster.poly_stipple_enable = 1;
+ raster->poly_stipple_enable = 1;
/* _NEW_BUFFERS, _NEW_POLYGON
*/
- if (raster.fill_cw != PIPE_POLYGON_MODE_FILL ||
- raster.fill_ccw != PIPE_POLYGON_MODE_FILL)
+ if (raster->fill_cw != PIPE_POLYGON_MODE_FILL ||
+ raster->fill_ccw != PIPE_POLYGON_MODE_FILL)
{
GLfloat mrd = (ctx->DrawBuffer ?
ctx->DrawBuffer->_MRD :
1.0);
- raster.offset_units = ctx->Polygon.OffsetFactor * mrd;
- raster.offset_scale = (ctx->Polygon.OffsetUnits * mrd *
+ raster->offset_units = ctx->Polygon.OffsetFactor * mrd;
+ raster->offset_scale = (ctx->Polygon.OffsetUnits * mrd *
st->polygon_offset_scale);
}
/* _NEW_POINT
*/
- raster.point_size = ctx->Point.Size;
- raster.point_smooth = ctx->Point.SmoothFlag;
- raster.point_sprite = ctx->Point.PointSprite;
+ raster->point_size = ctx->Point.Size;
+ raster->point_smooth = ctx->Point.SmoothFlag;
+ raster->point_sprite = ctx->Point.PointSprite;
for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
if (ctx->Point.CoordReplace[i]) {
if (ctx->Point.SpriteOrigin == GL_UPPER_LEFT)
- raster.sprite_coord_mode[i] = PIPE_SPRITE_COORD_UPPER_LEFT;
+ raster->sprite_coord_mode[i] = PIPE_SPRITE_COORD_UPPER_LEFT;
else
- raster.sprite_coord_mode[i] = PIPE_SPRITE_COORD_LOWER_LEFT;
+ raster->sprite_coord_mode[i] = PIPE_SPRITE_COORD_LOWER_LEFT;
}
else {
- raster.sprite_coord_mode[i] = PIPE_SPRITE_COORD_NONE;
+ raster->sprite_coord_mode[i] = PIPE_SPRITE_COORD_NONE;
}
}
if (vertProg) {
if (vertProg->Base.Id == 0) {
if (vertProg->Base.OutputsWritten & (1 << VERT_RESULT_PSIZ)) {
/* generated program which emits point size */
- raster.point_size_per_vertex = TRUE;
+ raster->point_size_per_vertex = TRUE;
}
}
else if (ctx->VertexProgram.PointSizeEnabled) {
/* user-defined program and GL_VERTEX_PROGRAM_POINT_SIZE set */
- raster.point_size_per_vertex = ctx->VertexProgram.PointSizeEnabled;
+ raster->point_size_per_vertex = ctx->VertexProgram.PointSizeEnabled;
}
}
/* _NEW_LINE
*/
- raster.line_smooth = ctx->Line.SmoothFlag;
+ raster->line_smooth = ctx->Line.SmoothFlag;
if (ctx->Line.SmoothFlag) {
- raster.line_width = CLAMP(ctx->Line.Width,
+ raster->line_width = CLAMP(ctx->Line.Width,
ctx->Const.MinLineWidthAA,
ctx->Const.MaxLineWidthAA);
}
else {
- raster.line_width = CLAMP(ctx->Line.Width,
+ raster->line_width = CLAMP(ctx->Line.Width,
ctx->Const.MinLineWidth,
ctx->Const.MaxLineWidth);
}
- raster.line_stipple_enable = ctx->Line.StippleFlag;
- raster.line_stipple_pattern = ctx->Line.StipplePattern;
+ raster->line_stipple_enable = ctx->Line.StippleFlag;
+ raster->line_stipple_pattern = ctx->Line.StipplePattern;
/* GL stipple factor is in [1,256], remap to [0, 255] here */
- raster.line_stipple_factor = ctx->Line.StippleFactor - 1;
+ raster->line_stipple_factor = ctx->Line.StippleFactor - 1;
/* _NEW_MULTISAMPLE */
if (ctx->Multisample.Enabled)
- raster.multisample = 1;
+ raster->multisample = 1;
/* _NEW_SCISSOR */
if (ctx->Scissor.Enabled)
- raster.scissor = 1;
+ raster->scissor = 1;
- cso = st_cached_rasterizer_state(st, &raster);
- if (st->state.rasterizer != cso) {
- st->state.rasterizer = cso;
- st->pipe->bind_rasterizer_state(st->pipe, cso->data);
- }
+ cso_set_rasterizer(st->cso_context, raster);
}
const struct st_tracked_state st_update_rasterizer = {
#include "st_context.h"
-#include "st_cache.h"
#include "st_atom.h"
#include "st_program.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
+#include "cso_cache/cso_context.h"
/**
/* loop over sampler units (aka tex image units) */
for (su = 0; su < st->ctx->Const.MaxTextureImageUnits; su++) {
- struct pipe_sampler_state sampler;
+ struct pipe_sampler_state *sampler = st->state.samplers + su;
- memset(&sampler, 0, sizeof(sampler));
+ memset(sampler, 0, sizeof(*sampler));
if (fs->Base.Base.SamplersUsed & (1 << su)) {
GLuint texUnit = fs->Base.Base.SamplerUnits[su];
assert(texobj);
- sampler.wrap_s = gl_wrap_to_sp(texobj->WrapS);
- sampler.wrap_t = gl_wrap_to_sp(texobj->WrapT);
- sampler.wrap_r = gl_wrap_to_sp(texobj->WrapR);
+ sampler->wrap_s = gl_wrap_to_sp(texobj->WrapS);
+ sampler->wrap_t = gl_wrap_to_sp(texobj->WrapT);
+ sampler->wrap_r = gl_wrap_to_sp(texobj->WrapR);
- sampler.min_img_filter = gl_filter_to_img_filter(texobj->MinFilter);
- sampler.min_mip_filter = gl_filter_to_mip_filter(texobj->MinFilter);
- sampler.mag_img_filter = gl_filter_to_img_filter(texobj->MagFilter);
+ sampler->min_img_filter = gl_filter_to_img_filter(texobj->MinFilter);
+ sampler->min_mip_filter = gl_filter_to_mip_filter(texobj->MinFilter);
+ sampler->mag_img_filter = gl_filter_to_img_filter(texobj->MagFilter);
if (texobj->Target != GL_TEXTURE_RECTANGLE_ARB)
- sampler.normalized_coords = 1;
+ sampler->normalized_coords = 1;
- sampler.lod_bias = st->ctx->Texture.Unit[su].LodBias;
+ sampler->lod_bias = st->ctx->Texture.Unit[su].LodBias;
#if 1
- sampler.min_lod = (texobj->MinLod) < 0.0 ? 0.0 : texobj->MinLod;
- sampler.max_lod = texobj->MaxLod;
+ sampler->min_lod = (texobj->MinLod) < 0.0 ? 0.0 : texobj->MinLod;
+ sampler->max_lod = texobj->MaxLod;
#else
/* min/max lod should really be as follows (untested).
* Also, calculate_first_last_level() needs to be overhauled
* since today's hardware had real support for LOD clamping.
*/
- sampler.min_lod = MAX2(texobj->BaseLevel, texobj->MinLod);
- sampler.max_lod = MIN2(texobj->MaxLevel, texobj->MaxLod);
+ sampler->min_lod = MAX2(texobj->BaseLevel, texobj->MinLod);
+ sampler->max_lod = MIN2(texobj->MaxLevel, texobj->MaxLod);
#endif
- sampler.max_anisotropy = texobj->MaxAnisotropy;
+ sampler->max_anisotropy = texobj->MaxAnisotropy;
/* only care about ARB_shadow, not SGI shadow */
if (texobj->CompareMode == GL_COMPARE_R_TO_TEXTURE) {
- sampler.compare = 1;
- sampler.compare_mode = PIPE_TEX_COMPARE_R_TO_TEXTURE;
- sampler.compare_func
+ sampler->compare = 1;
+ sampler->compare_mode = PIPE_TEX_COMPARE_R_TO_TEXTURE;
+ sampler->compare_func
= st_compare_func_to_pipe(texobj->CompareFunc);
}
/* XXX more sampler state here */
}
- st->state.sampler[su] = st_cached_sampler_state(st, &sampler)->data;
+ cso_single_sampler(st->cso_context, su, sampler);
}
- st->pipe->bind_sampler_states(st->pipe, st->state.num_samplers,
- st->state.sampler);
+ cso_single_sampler_done(st->cso_context);
}
#include "pipe/p_context.h"
#include "pipe/p_shader_tokens.h"
-#include "cso_cache/cso_cache.h"
+#include "cso_cache/cso_context.h"
#include "st_context.h"
-#include "st_cache.h"
#include "st_atom.h"
#include "st_program.h"
#include "st_atom_shader.h"
/** Maps VERT_RESULT_x to slot */
GLuint output_to_slot[VERT_RESULT_MAX];
- /** The program in TGSI format */
- struct tgsi_token tokens[ST_MAX_SHADER_TOKENS];
-
/** Pointer to the translated vertex program */
struct st_vertex_program *vp;
/*
* Translate fragment program if needed.
*/
- if (!stfp->cso) {
+ if (!stfp->state.tokens) {
GLuint inAttr, numIn = 0;
for (inAttr = 0; inAttr < FRAG_ATTRIB_MAX; inAttr++) {
assert(stfp->Base.Base.NumInstructions > 1);
- (void) st_translate_fragment_program(st, stfp,
- stfp->input_to_slot,
- stfp->tokens,
- ST_MAX_SHADER_TOKENS);
- assert(stfp->cso);
+ st_translate_fragment_program(st, stfp, stfp->input_to_slot);
}
assert(stvp->Base.Base.NumInstructions > 1);
- st_translate_vertex_program(st, stvp,
- xvp->output_to_slot,
- xvp->tokens,
- ST_MAX_SHADER_TOKENS);
+ st_translate_vertex_program(st, stvp, xvp->output_to_slot);
- assert(stvp->cso);
xvp->vp = stvp;
/* translated VP is up to date now */
xvp = find_translated_vp(st, stvp, stfp);
st->vp = stvp;
- st->state.vs = xvp->vp;
- st->pipe->bind_vs_state(st->pipe, st->state.vs->cso->data);
-
st->fp = stfp;
- st->state.fs = stfp->cso;
- st->pipe->bind_fs_state(st->pipe, st->state.fs->data);
+
+ st->pipe->bind_vs_state(st->pipe, stvp->driver_shader);
+ st->pipe->bind_fs_state(st->pipe, stfp->driver_shader);
st->vertex_result_to_slot = xvp->output_to_slot;
}
#include "main/macros.h"
#include "st_context.h"
-#include "st_cache.h"
#include "st_cb_accum.h"
#include "st_cb_fbo.h"
#include "st_draw.h"
#include "main/macros.h"
#include "shader/prog_instruction.h"
#include "st_atom.h"
-#include "st_cache.h"
#include "st_context.h"
#include "st_cb_accum.h"
#include "st_cb_clear.h"
#include "pipe/p_defines.h"
#include "pipe/p_winsys.h"
+#include "cso_cache/cso_context.h"
+
p->OutputsWritten = (1 << FRAG_RESULT_COLR);
stfp = (struct st_fragment_program *) p;
- st_translate_fragment_program(st, stfp, NULL,
- stfp->tokens, ST_MAX_SHADER_TOKENS);
+ st_translate_fragment_program(st, stfp, NULL);
return stfp;
}
(1 << VERT_RESULT_HPOS));
stvp = (struct st_vertex_program *) p;
- st_translate_vertex_program(st, stvp, NULL,
- stvp->tokens, ST_MAX_SHADER_TOKENS);
+ st_translate_vertex_program(st, stvp, NULL);
+#if 0
assert(stvp->cso);
+#endif
return stvp;
}
/* blend state: RGBA masking */
{
struct pipe_blend_state blend;
- const struct cso_blend *cso;
memset(&blend, 0, sizeof(blend));
if (color) {
if (ctx->Color.ColorMask[0])
if (st->ctx->Color.DitherFlag)
blend.dither = 1;
}
- cso = st_cached_blend_state(st, &blend);
- pipe->bind_blend_state(pipe, cso->data);
+ cso_set_blend(st->cso_context, &blend);
}
/* depth_stencil state: always pass/set to ref value */
{
struct pipe_depth_stencil_alpha_state depth_stencil;
- const struct cso_depth_stencil_alpha *cso;
memset(&depth_stencil, 0, sizeof(depth_stencil));
if (depth) {
depth_stencil.depth.enabled = 1;
depth_stencil.stencil[0].value_mask = 0xff;
depth_stencil.stencil[0].write_mask = ctx->Stencil.WriteMask[0] & 0xff;
}
- cso = st_cached_depth_stencil_alpha_state(st, &depth_stencil);
- pipe->bind_depth_stencil_alpha_state(pipe, cso->data);
+
+ cso_set_depth_stencil_alpha(st->cso_context, &depth_stencil);
}
/* rasterizer state: nothing */
{
struct pipe_rasterizer_state raster;
- const struct cso_rasterizer *cso;
memset(&raster, 0, sizeof(raster));
#if 0
/* don't do per-pixel scissor; we'll just draw a PIPE_PRIM_QUAD
if (ctx->Scissor.Enabled)
raster.scissor = 1;
#endif
- cso = st_cached_rasterizer_state(st, &raster);
- pipe->bind_rasterizer_state(pipe, cso->data);
+ cso_set_rasterizer(st->cso_context, &raster);
}
/* fragment shader state: color pass-through program */
if (!stfp) {
stfp = make_frag_shader(st);
}
- pipe->bind_fs_state(pipe, stfp->cso->data);
+ pipe->bind_fs_state(pipe, stfp->driver_shader);
}
/* vertex shader state: color/position pass-through */
if (!stvp) {
stvp = make_vertex_shader(st);
}
- pipe->bind_vs_state(pipe, stvp->cso->data);
+ pipe->bind_vs_state(pipe, stvp->driver_shader);
}
/* viewport state: viewport matching window dims */
/* draw quad matching scissor rect (XXX verify coord round-off) */
draw_quad(ctx, x0, y0, x1, y1, ctx->Depth.Clear, ctx->Color.ClearColor);
+#if 0
+ /* Can't depend on old state objects still existing -- may have
+ * been deleted to make room in the hash, etc. (Should get
+ * fixed...)
+ */
+ st_invalidate_state(ctx, _NEW_COLOR | _NEW_DEPTH | _NEW_STENCIL);
+#else
/* Restore pipe state */
- pipe->bind_blend_state(pipe, st->state.blend->data);
- pipe->bind_depth_stencil_alpha_state(pipe, st->state.depth_stencil->data);
- pipe->bind_fs_state(pipe, st->state.fs->data);
- pipe->bind_vs_state(pipe, st->state.vs->cso->data);
- pipe->bind_rasterizer_state(pipe, st->state.rasterizer->data);
+ cso_set_rasterizer(st->cso_context, &st->state.rasterizer);
+ pipe->bind_fs_state(pipe, st->fp->driver_shader);
+ pipe->bind_vs_state(pipe, st->vp->driver_shader);
+#endif
pipe->set_viewport_state(pipe, &st->state.viewport);
- /* OR:
- st_invalidate_state(ctx, _NEW_COLOR | _NEW_DEPTH | _NEW_STENCIL);
- */
}
#include "st_context.h"
#include "st_atom.h"
#include "st_atom_constbuf.h"
-#include "st_cache.h"
#include "st_draw.h"
#include "st_program.h"
#include "st_cb_drawpixels.h"
#include "pipe/p_winsys.h"
#include "util/p_tile.h"
#include "shader/prog_instruction.h"
+#include "cso_cache/cso_context.h"
/**
stfp = (struct st_fragment_program *) p;
stfp->Base.UsesKill = GL_TRUE;
- st_translate_fragment_program(ctx->st, stfp, NULL,
- stfp->tokens, ST_MAX_SHADER_TOKENS);
+ st_translate_fragment_program(ctx->st, stfp, NULL);
return stfp;
}
#endif
/* translate to TGSI tokens */
- st_translate_fragment_program(st, stfp, NULL,
- stfp->tokens, ST_MAX_SHADER_TOKENS);
+ st_translate_fragment_program(st, stfp, NULL);
/* save new program, update serial numbers */
st->bitmap.user_prog_sn = st->fp->serialNo;
#endif
/* translate to TGSI tokens */
- st_translate_fragment_program(st, stfp, NULL,
- stfp->tokens, ST_MAX_SHADER_TOKENS);
+ st_translate_fragment_program(st, stfp, NULL);
/* save new program, update serial numbers */
st->pixel_xfer.xfer_prog_sn = st->pixel_xfer.program->serialNo;
p->OutputsWritten = (1 << FRAG_RESULT_COLR) | (1 << FRAG_RESULT_DEPR);
stfp = (struct st_fragment_program *) p;
- st_translate_fragment_program(st, stfp, NULL,
- stfp->tokens, ST_MAX_SHADER_TOKENS);
+ st_translate_fragment_program(st, stfp, NULL);
return stfp;
}
}
stvp = (struct st_vertex_program *) p;
- st_translate_vertex_program(st, stvp, NULL,
- stvp->tokens, ST_MAX_SHADER_TOKENS);
+ st_translate_vertex_program(st, stvp, NULL);
progs[passColor] = stvp;
const GLfloat *color,
GLboolean invertTex)
{
+ struct st_context *st = ctx->st;
struct pipe_context *pipe = ctx->st->pipe;
+ struct cso_context *cso = ctx->st->cso_context;
GLfloat x0, y0, x1, y1;
GLuint maxSize;
/* setup state: just scissor */
{
struct pipe_rasterizer_state setup;
- const struct cso_rasterizer *cso;
memset(&setup, 0, sizeof(setup));
if (ctx->Scissor.Enabled)
setup.scissor = 1;
- cso = st_cached_rasterizer_state(ctx->st, &setup);
- pipe->bind_rasterizer_state(pipe, cso->data);
+
+ cso_set_rasterizer(cso, &setup);
}
/* fragment shader state: TEX lookup program */
- pipe->bind_fs_state(pipe, stfp->cso->data);
+ pipe->bind_fs_state(pipe, stfp->driver_shader);
/* vertex shader state: position + texcoord pass-through */
- pipe->bind_vs_state(pipe, stvp->cso->data);
+ pipe->bind_vs_state(pipe, stvp->driver_shader);
+
/* texture sampling state: */
{
struct pipe_sampler_state sampler;
- const struct cso_sampler *cso;
memset(&sampler, 0, sizeof(sampler));
sampler.wrap_s = PIPE_TEX_WRAP_CLAMP;
sampler.wrap_t = PIPE_TEX_WRAP_CLAMP;
sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST;
sampler.normalized_coords = 1;
- cso = st_cached_sampler_state(ctx->st, &sampler);
- pipe->bind_sampler_states(pipe, 1, (void**)&cso->data);
+
+ cso_single_sampler(cso, 0, &sampler);
+ cso_single_sampler_done(cso);
}
/* viewport state: viewport matching window dims */
draw_quad(ctx, x0, y0, z, x1, y1, invertTex);
/* restore GL state */
- pipe->bind_rasterizer_state(pipe, ctx->st->state.rasterizer->data);
- pipe->bind_fs_state(pipe, ctx->st->state.fs->data);
- pipe->bind_vs_state(pipe, ctx->st->state.vs->cso->data);
pipe->set_sampler_textures(pipe, ctx->st->state.num_textures,
ctx->st->state.sampler_texture);
- pipe->bind_sampler_states(pipe, ctx->st->state.num_samplers,
- ctx->st->state.sampler);
+
pipe->set_viewport_state(pipe, &ctx->st->state.viewport);
+
+#if 0
+ /* Can't depend on old state objects still existing -- may have
+ * been deleted to make room in the hash, etc. (Should get
+ * fixed...)
+ */
+ st_invalidate_state(ctx, _NEW_COLOR | _NEW_TEXTURE);
+#else
+ /* restore state */
+ pipe->bind_fs_state(pipe, st->fp->driver_shader);
+ pipe->bind_vs_state(pipe, st->vp->driver_shader);
+ cso_set_rasterizer(cso, &st->state.rasterizer);
+ cso_set_samplers(cso, PIPE_MAX_SAMPLERS,
+ (const struct pipe_sampler_state **) st->state.sampler_list);
+#endif
}
static GLboolean
any_fragment_ops(const struct st_context *st)
{
- if (st->state.depth_stencil->state.alpha.enabled ||
- st->state.blend->state.blend_enable ||
- st->state.blend->state.logicop_enable ||
- st->state.depth_stencil->state.depth.enabled)
+ if (st->state.depth_stencil.alpha.enabled ||
+ st->state.depth_stencil.depth.enabled ||
+ st->state.blend.blend_enable ||
+ st->state.blend.logicop_enable)
/* XXX more checks */
return GL_TRUE;
else
stfp->serialNo++;
+#if 0
if (stfp->cso) {
/* free the TGSI code */
// cso_delete(stfp->vs);
stfp->cso = NULL;
}
+#endif
stfp->param_state = stfp->Base.Base.Parameters->StateFlags;
stvp->serialNo++;
+#if 0
if (stvp->cso) {
/* free the CSO data */
st->pipe->delete_vs_state(st->pipe, stvp->cso->data);
FREE((void *) stvp->cso);
stvp->cso = NULL;
}
-
+#endif
if (stvp->draw_shader) {
draw_delete_vertex_shader(st->draw, stvp->draw_shader);
stvp->draw_shader = NULL;
#include "pipe/p_inlines.h"
#include "draw/draw_context.h"
#include "cso_cache/cso_cache.h"
+#include "cso_cache/cso_context.h"
/**
static struct st_context *
st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe )
{
+ uint i;
struct st_context *st = CALLOC_STRUCT( st_context );
ctx->st = st;
st->dirty.mesa = ~0;
st->dirty.st = ~0;
- st->cache = cso_cache_create();
+ st->cso_context = cso_create_context(pipe);
st_init_atoms( st );
st_init_draw( st );
st_init_generate_mipmap(st);
+ for (i = 0; i < PIPE_MAX_SAMPLERS; i++)
+ st->state.sampler_list[i] = &st->state.samplers[i];
+
/* we want all vertex data to be placed in buffer objects */
vbo_use_buffer_objects(ctx);
_vbo_DestroyContext(st->ctx);
- cso_cache_delete( st->cache );
+ cso_destroy_context(st->cso_context);
_mesa_delete_program_cache(st->ctx, st->pixel_xfer.cache);
* Other state is just parameter values.
*/
struct {
- const struct cso_alpha_test *alpha_test;
- const struct cso_blend *blend;
- void *sampler[PIPE_MAX_SAMPLERS];
- const struct cso_depth_stencil_alpha *depth_stencil;
- const struct cso_rasterizer *rasterizer;
- const struct cso_fragment_shader *fs;
- struct st_vertex_program *vs;
-
+ struct pipe_blend_state blend;
+ struct pipe_depth_stencil_alpha_state depth_stencil;
+ struct pipe_rasterizer_state rasterizer;
+ struct pipe_sampler_state samplers[PIPE_MAX_SAMPLERS];
+ struct pipe_sampler_state *sampler_list[PIPE_MAX_SAMPLERS];
struct pipe_blend_color blend_color;
struct pipe_clip_state clip;
struct pipe_constant_buffer constants[2];
/** For gen/render mipmap feature */
struct {
+ struct pipe_blend_state blend;
+ struct pipe_depth_stencil_alpha_state depthstencil;
+ struct pipe_rasterizer_state rasterizer;
+
void *blend_cso;
void *depthstencil_cso;
void *rasterizer_cso;
struct st_vertex_program *stvp;
} gen_mipmap;
- struct cso_cache *cache;
+ struct cso_context *cso_context;
};
int i;
printf("Vertex Transform Inputs:\n");
- for (i = 0; i < st->state.vs->cso->state.num_inputs; i++) {
+ for (i = 0; i < st->vp->state.num_inputs; i++) {
printf(" Slot %d: VERT_ATTRIB_%d\n", i, st->vp->index_to_input[i]);
}
- tgsi_dump( st->state.vs->cso->state.tokens, 0 );
+ tgsi_dump( st->vp->state.tokens, 0 );
if (st->vp->Base.Base.Parameters)
_mesa_print_parameter_list(st->vp->Base.Base.Parameters);
- tgsi_dump( st->state.fs->state.tokens, 0 );
+ tgsi_dump( st->fp->state.tokens, 0 );
if (st->fp->Base.Base.Parameters)
_mesa_print_parameter_list(st->fp->Base.Base.Parameters);
}
#include "vbo/vbo.h"
#include "st_atom.h"
-#include "st_cache.h"
#include "st_context.h"
#include "st_cb_bufferobjects.h"
#include "st_draw.h"
/* must get these after state validation! */
vp = ctx->st->vp;
- vs = &ctx->st->state.vs->cso->state;
+ vs = &ctx->st->vp->state;
/* loop over TGSI shader inputs to determine vertex buffer
* and attribute info
/* must get these after state validation! */
vp = ctx->st->vp;
- vs = &ctx->st->state.vs->cso->state;
+ vs = &st->vp->state;
- if (!st->state.vs->draw_shader) {
- st->state.vs->draw_shader = draw_create_vertex_shader(draw, vs);
+ if (!st->vp->draw_shader) {
+ st->vp->draw_shader = draw_create_vertex_shader(draw, vs);
}
/*
assert(draw);
draw_set_viewport_state(draw, &st->state.viewport);
draw_set_clip_state(draw, &st->state.clip);
- draw_set_rasterizer_state(draw, &st->state.rasterizer->state);
- draw_bind_vertex_shader(draw, st->state.vs->draw_shader);
+ draw_set_rasterizer_state(draw, &st->state.rasterizer);
+ draw_bind_vertex_shader(draw, st->vp->draw_shader);
set_feedback_vertex_format(ctx);
/* loop over TGSI shader inputs to determine vertex buffer
#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
#include "cso_cache/cso_cache.h"
+#include "cso_cache/cso_context.h"
#include "st_context.h"
#include "st_draw.h"
stfp = (struct st_fragment_program *) p;
- st_translate_fragment_program(ctx->st, stfp, NULL,
- stfp->tokens, ST_MAX_SHADER_TOKENS);
+ st_translate_fragment_program(ctx->st, stfp, NULL);
return stfp;
}
blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
blend.colormask = PIPE_MASK_RGBA;
+ st->gen_mipmap.blend = blend;
st->gen_mipmap.blend_cso = pipe->create_blend_state(pipe, &blend);
memset(&depthstencil, 0, sizeof(depthstencil));
sampler.normalized_coords = 1;
- /* bind CSOs */
- pipe->bind_blend_state(pipe, st->gen_mipmap.blend_cso);
- pipe->bind_depth_stencil_alpha_state(pipe, st->gen_mipmap.depthstencil_cso);
- pipe->bind_rasterizer_state(pipe, st->gen_mipmap.rasterizer_cso);
+ /* bind state */
+ cso_set_blend(st->cso_context, &st->gen_mipmap.blend);
+ cso_set_depth_stencil_alpha(st->cso_context, &st->gen_mipmap.depthstencil);
+ cso_set_rasterizer(st->cso_context, &st->gen_mipmap.rasterizer);
/* bind shaders */
- pipe->bind_fs_state(pipe, st->gen_mipmap.stfp->cso->data);
- pipe->bind_vs_state(pipe, st->gen_mipmap.stvp->cso->data);
+ pipe->bind_fs_state(pipe, st->gen_mipmap.stfp->driver_shader);
+ pipe->bind_vs_state(pipe, st->gen_mipmap.stvp->driver_shader);
/*
* XXX for small mipmap levels, it may be faster to use the software
/*pt->first_level = first_level_save;*/
/* restore pipe state */
- if (st->state.rasterizer)
- pipe->bind_rasterizer_state(pipe, st->state.rasterizer->data);
- if (st->state.fs)
- pipe->bind_fs_state(pipe, st->state.fs->data);
- if (st->state.vs)
- pipe->bind_vs_state(pipe, st->state.vs->cso->data);
- pipe->bind_sampler_states(pipe, st->state.num_samplers,
- st->state.sampler);
+#if 0
+ cso_set_rasterizer(st->cso_context, &st->state.rasterizer);
+ cso_set_samplers(st->cso_context, st->state.samplers_list);
+ pipe->bind_fs_state(pipe, st->fp->shader_program);
+ pipe->bind_vs_state(pipe, st->vp->shader_program);
pipe->set_sampler_textures(pipe, st->state.num_textures,
st->state.sampler_texture);
pipe->set_viewport_state(pipe, &st->state.viewport);
+#else
+ /* XXX is this sufficient? */
+ st_invalidate_state(st->ctx, _NEW_COLOR | _NEW_TEXTURE);
+#endif
return TRUE;
}
* \param tokens array to store translated tokens in
* \param maxTokens size of the tokens array
*
+ * \return number of tokens placed in 'tokens' buffer, or zero if error
*/
-GLboolean
+GLuint
tgsi_translate_mesa_program(
uint procType,
const struct gl_program *program,
maxTokens - ti );
}
- return GL_TRUE;
+ return ti;
}
struct tgsi_token;
struct gl_program;
-GLboolean
+GLuint
tgsi_translate_mesa_program(
uint procType,
const struct gl_program *program,
#include "tgsi/util/tgsi_dump.h"
#include "st_context.h"
-#include "st_cache.h"
#include "st_atom.h"
#include "st_program.h"
#include "st_mesa_to_tgsi.h"
+#include "cso_cache/cso_context.h"
#define TGSI_DEBUG 0
+/** XXX we should use the version of this from p_util.h but including
+ * that header causes symbol collisions.
+ */
+static INLINE void *
+mem_dup(const void *src, uint size)
+{
+ void *dup = MALLOC(size);
+ if (dup)
+ memcpy(dup, src, size);
+ return dup;
+}
+
+
+
/**
* Translate a Mesa vertex shader into a TGSI shader.
* \param outputMapping to map vertex program output registers to TGSI
void
st_translate_vertex_program(struct st_context *st,
struct st_vertex_program *stvp,
- const GLuint outputMapping[],
- struct tgsi_token *tokensOut,
- GLuint maxTokens)
+ const GLuint outputMapping[])
{
+ struct pipe_context *pipe = st->pipe;
+ struct tgsi_token tokens[ST_MAX_SHADER_TOKENS];
GLuint defaultOutputMapping[VERT_RESULT_MAX];
struct pipe_shader_state vs;
- const struct cso_vertex_shader *cso;
GLuint attr, i;
GLuint num_generic = 0;
+ GLuint num_tokens;
memset(&vs, 0, sizeof(vs));
/* XXX: fix static allocation of tokens:
*/
- tgsi_translate_mesa_program( TGSI_PROCESSOR_VERTEX,
+ num_tokens = tgsi_translate_mesa_program( TGSI_PROCESSOR_VERTEX,
&stvp->Base.Base,
/* inputs */
vs.num_inputs,
vs.num_outputs,
outputMapping,
vs.output_semantic_name,
- vs.output_semantic_index,
+ vs.output_semantic_index,
/* tokenized result */
- tokensOut, maxTokens);
+ tokens, ST_MAX_SHADER_TOKENS);
- vs.tokens = tokensOut;
+ vs.tokens = (struct tgsi_token *)
+ mem_dup(tokens, num_tokens * sizeof(tokens[0]));
- cso = st_cached_vs_state(st, &vs);
- stvp->cso = cso;
+ stvp->state = vs; /* struct copy */
+ stvp->driver_shader = pipe->create_vs_state(pipe, &vs);
if (0)
_mesa_print_program(&stvp->Base.Base);
if (TGSI_DEBUG)
- tgsi_dump( tokensOut, 0 );
+ tgsi_dump( vs.tokens, 0 );
}
const struct cso_fragment_shader *
st_translate_fragment_program(struct st_context *st,
struct st_fragment_program *stfp,
- const GLuint inputMapping[],
- struct tgsi_token *tokensOut,
- GLuint maxTokens)
+ const GLuint inputMapping[])
{
+ struct pipe_context *pipe = st->pipe;
+ struct tgsi_token tokens[ST_MAX_SHADER_TOKENS];
GLuint outputMapping[FRAG_RESULT_MAX];
GLuint defaultInputMapping[FRAG_ATTRIB_MAX];
struct pipe_shader_state fs;
const GLbitfield inputsRead = stfp->Base.Base.InputsRead;
GLuint vslot = 0;
GLuint num_generic = 0;
+ GLuint num_tokens;
memset(&fs, 0, sizeof(fs));
/* XXX: fix static allocation of tokens:
*/
- tgsi_translate_mesa_program( TGSI_PROCESSOR_FRAGMENT,
+ num_tokens = tgsi_translate_mesa_program( TGSI_PROCESSOR_FRAGMENT,
&stfp->Base.Base,
/* inputs */
fs.num_inputs,
fs.output_semantic_name,
fs.output_semantic_index,
/* tokenized result */
- tokensOut, maxTokens);
+ tokens, ST_MAX_SHADER_TOKENS);
- fs.tokens = tokensOut;
+ fs.tokens = (struct tgsi_token *)
+ mem_dup(tokens, num_tokens * sizeof(tokens[0]));
- cso = st_cached_fs_state(st, &fs);
- stfp->cso = cso;
+ stfp->state = fs; /* struct copy */
+ stfp->driver_shader = pipe->create_fs_state(pipe, &fs);
if (0)
_mesa_print_program(&stfp->Base.Base);
if (TGSI_DEBUG)
- tgsi_dump( tokensOut, 0/*TGSI_DUMP_VERBOSE*/ );
+ tgsi_dump( fs.tokens, 0/*TGSI_DUMP_VERBOSE*/ );
return cso;
}
/** map FP input back to VP output */
GLuint input_map[PIPE_MAX_SHADER_INPUTS];
- /** The program in TGSI format */
- struct tgsi_token tokens[ST_MAX_SHADER_TOKENS];
-
- /** Pointer to the corresponding cached shader */
- const struct cso_fragment_shader *cso;
+ struct pipe_shader_state state;
+ struct pipe_shader_state *driver_shader;
GLuint param_state;
/** maps a TGSI input index back to a Mesa VERT_ATTRIB_x */
GLuint index_to_input[PIPE_MAX_SHADER_INPUTS];
- /** The program in TGSI format */
- struct tgsi_token tokens[ST_MAX_SHADER_TOKENS];
-
- /** Pointer to the corresponding cached shader */
- const struct cso_vertex_shader *cso;
+ struct pipe_shader_state state;
+ struct pipe_shader_state *driver_shader;
/** For using our private draw module (glRasterPos) */
struct draw_vertex_shader *draw_shader;
extern const struct cso_fragment_shader *
st_translate_fragment_program(struct st_context *st,
struct st_fragment_program *fp,
- const GLuint inputMapping[],
- struct tgsi_token *tokens,
- GLuint maxTokens);
+ const GLuint inputMapping[]);
extern void
st_translate_vertex_program(struct st_context *st,
struct st_vertex_program *vp,
- const GLuint vert_output_to_slot[],
- struct tgsi_token *tokens,
- GLuint maxTokens);
+ const GLuint vert_output_to_slot[]);
#endif