/**************************************************************************
*
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2007 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
struct aaline_fragment_shader *fs;
struct {
void *sampler[PIPE_MAX_SAMPLERS];
- struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
+ struct pipe_sampler_view *sampler_views[PIPE_MAX_SHADER_SAMPLER_VIEWS];
} state;
/*
void (*driver_bind_fs_state)(struct pipe_context *, void *);
void (*driver_delete_fs_state)(struct pipe_context *, void *);
- void (*driver_bind_sampler_states)(struct pipe_context *, unsigned,
- void **);
+ void (*driver_bind_sampler_states)(struct pipe_context *, unsigned, unsigned,
+ unsigned, void **);
- void (*driver_set_sampler_views)(struct pipe_context *,
- unsigned,
+ void (*driver_set_sampler_views)(struct pipe_context *, unsigned shader,
+ unsigned start, unsigned count,
struct pipe_sampler_view **);
};
/* This texture is new, no need to flush.
*/
- transfer = pipe->get_transfer(pipe,
- aaline->texture,
- level,
- PIPE_TRANSFER_WRITE,
- &box);
+ data = pipe->transfer_map(pipe,
+ aaline->texture,
+ level,
+ PIPE_TRANSFER_WRITE,
+ &box, &transfer);
- data = pipe->transfer_map(pipe, transfer);
if (data == NULL)
return FALSE;
/* unmap */
pipe->transfer_unmap(pipe, transfer);
- pipe->transfer_destroy(pipe, transfer);
}
return TRUE;
}
return;
}
- /* update vertex attrib info */
- aaline->pos_slot = draw_current_shader_position_output(draw);;
-
- /* allocate the extra post-transformed vertex attribute */
- aaline->tex_slot = draw_alloc_extra_vertex_attrib(draw,
- TGSI_SEMANTIC_GENERIC,
- aaline->fs->generic_attrib);
+ draw_aaline_prepare_outputs(draw, draw->pipeline.aaline);
/* how many samplers? */
/* we'll use sampler/texture[pstip->sampler_unit] for the stipple */
aaline->sampler_view);
draw->suspend_flushing = TRUE;
- aaline->driver_bind_sampler_states(pipe, num_samplers, aaline->state.sampler);
- aaline->driver_set_sampler_views(pipe, num_samplers, aaline->state.sampler_views);
+
+ aaline->driver_bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT, 0,
+ num_samplers, aaline->state.sampler);
+
+ aaline->driver_set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0,
+ num_samplers, aaline->state.sampler_views);
/* Disable triangle culling, stippling, unfilled mode etc. */
r = draw_get_rasterizer_no_cull(draw, rast->scissor, rast->flatshade);
/* restore original frag shader, texture, sampler state */
draw->suspend_flushing = TRUE;
aaline->driver_bind_fs_state(pipe, aaline->fs ? aaline->fs->driver_fs : NULL);
- aaline->driver_bind_sampler_states(pipe, aaline->num_samplers,
+
+ aaline->driver_bind_sampler_states(pipe, PIPE_SHADER_FRAGMENT, 0,
+ aaline->num_samplers,
aaline->state.sampler);
- aaline->driver_set_sampler_views(pipe,
- aaline->num_sampler_views,
+
+ aaline->driver_set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0,
+ aaline->num_samplers,
aaline->state.sampler_views);
/* restore original rasterizer state */
struct pipe_context *pipe = stage->draw->pipe;
uint i;
- for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
+ for (i = 0; i < PIPE_MAX_SHADER_SAMPLER_VIEWS; i++) {
pipe_sampler_view_reference(&aaline->state.sampler_views[i], NULL);
}
pipe->bind_fs_state = aaline->driver_bind_fs_state;
pipe->delete_fs_state = aaline->driver_delete_fs_state;
- pipe->bind_fragment_sampler_states = aaline->driver_bind_sampler_states;
- pipe->set_fragment_sampler_views = aaline->driver_set_sampler_views;
+ pipe->bind_sampler_states = aaline->driver_bind_sampler_states;
+ pipe->set_sampler_views = aaline->driver_set_sampler_views;
FREE( stage );
}
aaline_stage_from_pipe(struct pipe_context *pipe)
{
struct draw_context *draw = (struct draw_context *) pipe->draw;
- return aaline_stage(draw->pipeline.aaline);
+
+ if (draw) {
+ return aaline_stage(draw->pipeline.aaline);
+ } else {
+ return NULL;
+ }
}
const struct pipe_shader_state *fs)
{
struct aaline_stage *aaline = aaline_stage_from_pipe(pipe);
- struct aaline_fragment_shader *aafs = CALLOC_STRUCT(aaline_fragment_shader);
+ struct aaline_fragment_shader *aafs = NULL;
+
+ if (aaline == NULL)
+ return NULL;
+
+ aafs = CALLOC_STRUCT(aaline_fragment_shader);
if (aafs == NULL)
return NULL;
struct aaline_stage *aaline = aaline_stage_from_pipe(pipe);
struct aaline_fragment_shader *aafs = (struct aaline_fragment_shader *) fs;
+ if (aaline == NULL) {
+ return;
+ }
+
/* save current */
aaline->fs = aafs;
/* pass-through */
struct aaline_stage *aaline = aaline_stage_from_pipe(pipe);
struct aaline_fragment_shader *aafs = (struct aaline_fragment_shader *) fs;
- /* pass-through */
- aaline->driver_delete_fs_state(pipe, aafs->driver_fs);
+ if (aafs == NULL) {
+ return;
+ }
- if (aafs->aaline_fs)
- aaline->driver_delete_fs_state(pipe, aafs->aaline_fs);
+ if (aaline != NULL) {
+ /* pass-through */
+ aaline->driver_delete_fs_state(pipe, aafs->driver_fs);
- FREE((void*)aafs->state.tokens);
+ if (aafs->aaline_fs)
+ aaline->driver_delete_fs_state(pipe, aafs->aaline_fs);
+ }
+ FREE((void*)aafs->state.tokens);
FREE(aafs);
}
static void
-aaline_bind_sampler_states(struct pipe_context *pipe,
- unsigned num, void **sampler)
+aaline_bind_sampler_states(struct pipe_context *pipe, unsigned shader,
+ unsigned start, unsigned num, void **sampler)
{
struct aaline_stage *aaline = aaline_stage_from_pipe(pipe);
- /* save current */
- memcpy(aaline->state.sampler, sampler, num * sizeof(void *));
- aaline->num_samplers = num;
+ assert(start == 0);
+
+ if (aaline == NULL) {
+ return;
+ }
+
+ if (shader == PIPE_SHADER_FRAGMENT) {
+ /* save current */
+ memcpy(aaline->state.sampler, sampler, num * sizeof(void *));
+ aaline->num_samplers = num;
+ }
/* pass-through */
- aaline->driver_bind_sampler_states(pipe, num, sampler);
+ aaline->driver_bind_sampler_states(pipe, shader, start, num, sampler);
}
static void
-aaline_set_sampler_views(struct pipe_context *pipe,
- unsigned num,
+aaline_set_sampler_views(struct pipe_context *pipe, unsigned shader,
+ unsigned start, unsigned num,
struct pipe_sampler_view **views)
{
struct aaline_stage *aaline = aaline_stage_from_pipe(pipe);
uint i;
- /* save current */
- for (i = 0; i < num; i++) {
- pipe_sampler_view_reference(&aaline->state.sampler_views[i], views[i]);
+ if (aaline == NULL) {
+ return;
}
- for ( ; i < PIPE_MAX_SAMPLERS; i++) {
- pipe_sampler_view_reference(&aaline->state.sampler_views[i], NULL);
+
+ if (shader == PIPE_SHADER_FRAGMENT) {
+ /* save current */
+ for (i = 0; i < num; i++) {
+ pipe_sampler_view_reference(&aaline->state.sampler_views[start + i],
+ views[i]);
+ }
+ aaline->num_sampler_views = num;
}
- aaline->num_sampler_views = num;
/* pass-through */
- aaline->driver_set_sampler_views(pipe, num, views);
+ aaline->driver_set_sampler_views(pipe, shader, start, num, views);
}
+void
+draw_aaline_prepare_outputs(struct draw_context *draw,
+ struct draw_stage *stage)
+{
+ struct aaline_stage *aaline = aaline_stage(stage);
+ const struct pipe_rasterizer_state *rast = draw->rasterizer;
+
+ /* update vertex attrib info */
+ aaline->pos_slot = draw_current_shader_position_output(draw);;
+
+ if (!rast->line_smooth)
+ return;
+
+ /* allocate the extra post-transformed vertex attribute */
+ aaline->tex_slot = draw_alloc_extra_vertex_attrib(draw,
+ TGSI_SEMANTIC_GENERIC,
+ aaline->fs->generic_attrib);
+}
+
/**
* Called by drivers that want to install this AA line prim stage
* into the draw module's pipeline. This will not be used if the
aaline->driver_bind_fs_state = pipe->bind_fs_state;
aaline->driver_delete_fs_state = pipe->delete_fs_state;
- aaline->driver_bind_sampler_states = pipe->bind_fragment_sampler_states;
- aaline->driver_set_sampler_views = pipe->set_fragment_sampler_views;
+ aaline->driver_bind_sampler_states = pipe->bind_sampler_states;
+ aaline->driver_set_sampler_views = pipe->set_sampler_views;
/* override the driver's functions */
pipe->create_fs_state = aaline_create_fs_state;
pipe->bind_fs_state = aaline_bind_fs_state;
pipe->delete_fs_state = aaline_delete_fs_state;
- pipe->bind_fragment_sampler_states = aaline_bind_sampler_states;
- pipe->set_fragment_sampler_views = aaline_set_sampler_views;
+ pipe->bind_sampler_states = aaline_bind_sampler_states;
+ pipe->set_sampler_views = aaline_set_sampler_views;
/* Install once everything is known to be OK:
*/