projects
/
mesa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
gallivm: added lp_build_andc()
[mesa.git]
/
src
/
gallium
/
auxiliary
/
draw
/
draw_pipe_aaline.c
diff --git
a/src/gallium/auxiliary/draw/draw_pipe_aaline.c
b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
index dbeb22b91735f798ce288d9a17b090064895ba5a..f4615064e655e66a9eb2415af4bba4182de519eb 100644
(file)
--- a/
src/gallium/auxiliary/draw/draw_pipe_aaline.c
+++ b/
src/gallium/auxiliary/draw/draw_pipe_aaline.c
@@
-35,10
+35,12
@@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
+#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
+#include "util/u_sampler.h"
#include "tgsi/tgsi_transform.h"
#include "tgsi/tgsi_dump.h"
#include "tgsi/tgsi_transform.h"
#include "tgsi/tgsi_dump.h"
@@
-48,6
+50,10
@@
#include "draw_pipe.h"
#include "draw_pipe.h"
+/** Approx number of new tokens for instructions in aa_transform_inst() */
+#define NUM_NEW_TOKENS 50
+
+
/**
* Max texture level for the alpha texture used for antialiasing
*/
/**
* Max texture level for the alpha texture used for antialiasing
*/
@@
-83,8
+89,9
@@
struct aaline_stage
void *sampler_cso;
struct pipe_texture *texture;
void *sampler_cso;
struct pipe_texture *texture;
+ struct pipe_sampler_view *sampler_view;
uint num_samplers;
uint num_samplers;
- uint num_
texture
s;
+ uint num_
sampler_view
s;
/*
/*
@@
-93,7
+100,7
@@
struct aaline_stage
struct aaline_fragment_shader *fs;
struct {
void *sampler[PIPE_MAX_SAMPLERS];
struct aaline_fragment_shader *fs;
struct {
void *sampler[PIPE_MAX_SAMPLERS];
- struct pipe_
texture *texture
[PIPE_MAX_SAMPLERS];
+ struct pipe_
sampler_view *sampler_views
[PIPE_MAX_SAMPLERS];
} state;
/*
} state;
/*
@@
-106,8
+113,9
@@
struct aaline_stage
void (*driver_bind_sampler_states)(struct pipe_context *, unsigned,
void **);
void (*driver_bind_sampler_states)(struct pipe_context *, unsigned,
void **);
- void (*driver_set_sampler_textures)(struct pipe_context *, unsigned,
- struct pipe_texture **);
+ void (*driver_set_sampler_views)(struct pipe_context *,
+ unsigned,
+ struct pipe_sampler_view **);
struct pipe_context *pipe;
};
struct pipe_context *pipe;
};
@@
-178,12
+186,7
@@
aa_transform_decl(struct tgsi_transform_context *ctx,
static int
free_bit(uint bitfield)
{
static int
free_bit(uint bitfield)
{
- int i;
- for (i = 0; i < 32; i++) {
- if ((bitfield & (1 << i)) == 0)
- return i;
- }
- return -1;
+ return ffs(~bitfield) - 1;
}
}
@@
-342,11
+345,10
@@
generate_aaline_fs(struct aaline_stage *aaline)
const struct pipe_shader_state *orig_fs = &aaline->fs->state;
struct pipe_shader_state aaline_fs;
struct aa_transform_context transform;
const struct pipe_shader_state *orig_fs = &aaline->fs->state;
struct pipe_shader_state aaline_fs;
struct aa_transform_context transform;
-
-#define MAX 1000
+ const uint newLen = tgsi_num_tokens(orig_fs->tokens) + NUM_NEW_TOKENS;
aaline_fs = *orig_fs; /* copy to init */
aaline_fs = *orig_fs; /* copy to init */
- aaline_fs.tokens =
MALLOC(sizeof(struct tgsi_token) * MAX
);
+ aaline_fs.tokens =
tgsi_alloc_tokens(newLen
);
if (aaline_fs.tokens == NULL)
return FALSE;
if (aaline_fs.tokens == NULL)
return FALSE;
@@
-362,7
+364,7
@@
generate_aaline_fs(struct aaline_stage *aaline)
tgsi_transform_shader(orig_fs->tokens,
(struct tgsi_token *) aaline_fs.tokens,
tgsi_transform_shader(orig_fs->tokens,
(struct tgsi_token *) aaline_fs.tokens,
-
MAX
, &transform.base);
+
newLen
, &transform.base);
#if 0 /* DEBUG */
tgsi_dump(orig_fs->tokens, 0);
#if 0 /* DEBUG */
tgsi_dump(orig_fs->tokens, 0);
@@
-395,6
+397,7
@@
aaline_create_texture(struct aaline_stage *aaline)
struct pipe_context *pipe = aaline->pipe;
struct pipe_screen *screen = pipe->screen;
struct pipe_texture texTemp;
struct pipe_context *pipe = aaline->pipe;
struct pipe_screen *screen = pipe->screen;
struct pipe_texture texTemp;
+ struct pipe_sampler_view viewTempl;
uint level;
memset(&texTemp, 0, sizeof(texTemp));
uint level;
memset(&texTemp, 0, sizeof(texTemp));
@@
-404,12
+407,21
@@
aaline_create_texture(struct aaline_stage *aaline)
texTemp.width0 = 1 << MAX_TEXTURE_LEVEL;
texTemp.height0 = 1 << MAX_TEXTURE_LEVEL;
texTemp.depth0 = 1;
texTemp.width0 = 1 << MAX_TEXTURE_LEVEL;
texTemp.height0 = 1 << MAX_TEXTURE_LEVEL;
texTemp.depth0 = 1;
- util_format_get_block(texTemp.format, &texTemp.block);
aaline->texture = screen->texture_create(screen, &texTemp);
if (!aaline->texture)
return FALSE;
aaline->texture = screen->texture_create(screen, &texTemp);
if (!aaline->texture)
return FALSE;
+ u_sampler_view_default_template(&viewTempl,
+ aaline->texture,
+ aaline->texture->format);
+ aaline->sampler_view = pipe->create_sampler_view(pipe,
+ aaline->texture,
+ &viewTempl);
+ if (!aaline->sampler_view) {
+ return FALSE;
+ }
+
/* Fill in mipmap images.
* Basically each level is solid opaque, except for the outermost
* texels which are zero. Special case the 1x1 and 2x2 levels.
/* Fill in mipmap images.
* Basically each level is solid opaque, except for the outermost
* texels which are zero. Special case the 1x1 and 2x2 levels.
@@
-424,9
+436,9
@@
aaline_create_texture(struct aaline_stage *aaline)
/* This texture is new, no need to flush.
*/
/* This texture is new, no need to flush.
*/
- transfer =
screen->get_tex_transfer(screen
, aaline->texture, 0, level, 0,
+ transfer =
pipe->get_tex_transfer(pipe
, aaline->texture, 0, level, 0,
PIPE_TRANSFER_WRITE, 0, 0, size, size);
PIPE_TRANSFER_WRITE, 0, 0, size, size);
- data =
screen->transfer_map(screen
, transfer);
+ data =
pipe->transfer_map(pipe
, transfer);
if (data == NULL)
return FALSE;
if (data == NULL)
return FALSE;
@@
-450,8
+462,8
@@
aaline_create_texture(struct aaline_stage *aaline)
}
/* unmap */
}
/* unmap */
-
screen->transfer_unmap(screen
, transfer);
-
screen->tex_transfer_destroy(
transfer);
+
pipe->transfer_unmap(pipe
, transfer);
+
pipe->tex_transfer_destroy(pipe,
transfer);
}
return TRUE;
}
}
return TRUE;
}
@@
-661,26
+673,26
@@
aaline_first_line(struct draw_stage *stage, struct prim_header *header)
}
/* update vertex attrib info */
}
/* update vertex attrib info */
- aaline->tex_slot = draw
->vs.num_vs_outputs
;
- aaline->pos_slot = draw
->vs.position_output
;
+ aaline->tex_slot = draw
_current_shader_outputs(draw)
;
+ aaline->pos_slot = draw
_current_shader_position_output(draw);
;
/* advertise the extra post-transformed vertex attribute */
/* advertise the extra post-transformed vertex attribute */
- draw->extra_
vp
_outputs.semantic_name = TGSI_SEMANTIC_GENERIC;
- draw->extra_
vp
_outputs.semantic_index = aaline->fs->generic_attrib;
- draw->extra_
vp
_outputs.slot = aaline->tex_slot;
+ draw->extra_
shader
_outputs.semantic_name = TGSI_SEMANTIC_GENERIC;
+ draw->extra_
shader
_outputs.semantic_index = aaline->fs->generic_attrib;
+ draw->extra_
shader
_outputs.slot = aaline->tex_slot;
/* how many samplers? */
/* we'll use sampler/texture[pstip->sampler_unit] for the stipple */
/* how many samplers? */
/* we'll use sampler/texture[pstip->sampler_unit] for the stipple */
- num_samplers = MAX2(aaline->num_
texture
s, aaline->num_samplers);
+ num_samplers = MAX2(aaline->num_
sampler_view
s, aaline->num_samplers);
num_samplers = MAX2(num_samplers, aaline->fs->sampler_unit + 1);
aaline->state.sampler[aaline->fs->sampler_unit] = aaline->sampler_cso;
num_samplers = MAX2(num_samplers, aaline->fs->sampler_unit + 1);
aaline->state.sampler[aaline->fs->sampler_unit] = aaline->sampler_cso;
- pipe_
texture_reference(&aaline->state.texture
[aaline->fs->sampler_unit],
-
aaline->texture
);
+ pipe_
sampler_view_reference(&aaline->state.sampler_views
[aaline->fs->sampler_unit],
+
aaline->sampler_view
);
draw->suspend_flushing = TRUE;
aaline->driver_bind_sampler_states(pipe, num_samplers, aaline->state.sampler);
draw->suspend_flushing = TRUE;
aaline->driver_bind_sampler_states(pipe, num_samplers, aaline->state.sampler);
- aaline->driver_set_sampler_
textures(pipe, num_samplers, aaline->state.texture
);
+ aaline->driver_set_sampler_
views(pipe, num_samplers, aaline->state.sampler_views
);
draw->suspend_flushing = FALSE;
/* now really draw first line */
draw->suspend_flushing = FALSE;
/* now really draw first line */
@@
-704,11
+716,12
@@
aaline_flush(struct draw_stage *stage, unsigned flags)
aaline->driver_bind_fs_state(pipe, aaline->fs->driver_fs);
aaline->driver_bind_sampler_states(pipe, aaline->num_samplers,
aaline->state.sampler);
aaline->driver_bind_fs_state(pipe, aaline->fs->driver_fs);
aaline->driver_bind_sampler_states(pipe, aaline->num_samplers,
aaline->state.sampler);
- aaline->driver_set_sampler_textures(pipe, aaline->num_textures,
- aaline->state.texture);
+ aaline->driver_set_sampler_views(pipe,
+ aaline->num_sampler_views,
+ aaline->state.sampler_views);
draw->suspend_flushing = FALSE;
draw->suspend_flushing = FALSE;
- draw->extra_
vp
_outputs.slot = 0;
+ draw->extra_
shader
_outputs.slot = 0;
}
}
@@
-726,7
+739,7
@@
aaline_destroy(struct draw_stage *stage)
uint i;
for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
uint i;
for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
- pipe_
texture_reference(&aaline->state.texture
[i], NULL);
+ pipe_
sampler_view_reference(&aaline->state.sampler_views
[i], NULL);
}
if (aaline->sampler_cso)
}
if (aaline->sampler_cso)
@@
-735,6
+748,10
@@
aaline_destroy(struct draw_stage *stage)
if (aaline->texture)
pipe_texture_reference(&aaline->texture, NULL);
if (aaline->texture)
pipe_texture_reference(&aaline->texture, NULL);
+ if (aaline->sampler_view) {
+ pipe_sampler_view_reference(&aaline->sampler_view, NULL);
+ }
+
draw_free_temp_verts( stage );
FREE( stage );
draw_free_temp_verts( stage );
FREE( stage );
@@
-846,23
+863,24
@@
aaline_bind_sampler_states(struct pipe_context *pipe,
static void
static void
-aaline_set_sampler_textures(struct pipe_context *pipe,
- unsigned num, struct pipe_texture **texture)
+aaline_set_sampler_views(struct pipe_context *pipe,
+ 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++) {
{
struct aaline_stage *aaline = aaline_stage_from_pipe(pipe);
uint i;
/* save current */
for (i = 0; i < num; i++) {
- pipe_
texture_reference(&aaline->state.texture[i], texture
[i]);
+ pipe_
sampler_view_reference(&aaline->state.sampler_views[i], views
[i]);
}
for ( ; i < PIPE_MAX_SAMPLERS; i++) {
}
for ( ; i < PIPE_MAX_SAMPLERS; i++) {
- pipe_
texture_reference(&aaline->state.texture
[i], NULL);
+ pipe_
sampler_view_reference(&aaline->state.sampler_views
[i], NULL);
}
}
- aaline->num_
texture
s = num;
+ aaline->num_
sampler_view
s = num;
/* pass-through */
/* pass-through */
- aaline->driver_set_sampler_
textures(aaline->pipe, num, texture
);
+ aaline->driver_set_sampler_
views(aaline->pipe, num, views
);
}
}
@@
-900,7
+918,7
@@
draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe)
aaline->driver_delete_fs_state = pipe->delete_fs_state;
aaline->driver_bind_sampler_states = pipe->bind_fragment_sampler_states;
aaline->driver_delete_fs_state = pipe->delete_fs_state;
aaline->driver_bind_sampler_states = pipe->bind_fragment_sampler_states;
- aaline->driver_set_sampler_
textures = pipe->set_fragment_sampler_texture
s;
+ aaline->driver_set_sampler_
views = pipe->set_fragment_sampler_view
s;
/* override the driver's functions */
pipe->create_fs_state = aaline_create_fs_state;
/* override the driver's functions */
pipe->create_fs_state = aaline_create_fs_state;
@@
-908,7
+926,7
@@
draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe)
pipe->delete_fs_state = aaline_delete_fs_state;
pipe->bind_fragment_sampler_states = aaline_bind_sampler_states;
pipe->delete_fs_state = aaline_delete_fs_state;
pipe->bind_fragment_sampler_states = aaline_bind_sampler_states;
- pipe->set_fragment_sampler_
textures = aaline_set_sampler_texture
s;
+ pipe->set_fragment_sampler_
views = aaline_set_sampler_view
s;
/* Install once everything is known to be OK:
*/
/* Install once everything is known to be OK:
*/