llvmpipe: Pass state to setup.
This commit is contained in:
parent
00ffef383c
commit
d904ed88c1
|
@ -59,7 +59,7 @@ struct llvmpipe_context {
|
||||||
const struct lp_vertex_shader *vs;
|
const struct lp_vertex_shader *vs;
|
||||||
|
|
||||||
/** Other rendering state */
|
/** Other rendering state */
|
||||||
struct pipe_blend_color blend_color[4][16];
|
struct pipe_blend_color blend_color;
|
||||||
struct pipe_clip_state clip;
|
struct pipe_clip_state clip;
|
||||||
struct pipe_constant_buffer constants[PIPE_SHADER_TYPES];
|
struct pipe_constant_buffer constants[PIPE_SHADER_TYPES];
|
||||||
struct pipe_framebuffer_state framebuffer;
|
struct pipe_framebuffer_state framebuffer;
|
||||||
|
@ -120,7 +120,6 @@ struct llvmpipe_context {
|
||||||
unsigned tex_timestamp;
|
unsigned tex_timestamp;
|
||||||
boolean no_rast;
|
boolean no_rast;
|
||||||
|
|
||||||
struct lp_jit_context jit_context;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,11 +32,15 @@
|
||||||
* lp_setup_flush().
|
* lp_setup_flush().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "lp_setup_context.h"
|
#include "pipe/p_defines.h"
|
||||||
|
#include "pipe/p_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_pack_color.h"
|
#include "util/u_pack_color.h"
|
||||||
#include "pipe/p_defines.h"
|
#include "lp_state.h"
|
||||||
|
#include "lp_buffer.h"
|
||||||
|
#include "lp_texture.h"
|
||||||
|
#include "lp_setup_context.h"
|
||||||
|
|
||||||
static void set_state( struct setup_context *, unsigned );
|
static void set_state( struct setup_context *, unsigned );
|
||||||
|
|
||||||
|
@ -394,16 +398,101 @@ lp_setup_set_fs_inputs( struct setup_context *setup,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
lp_setup_set_fs( struct setup_context *setup,
|
||||||
|
struct lp_fragment_shader *fs )
|
||||||
|
{
|
||||||
|
/* FIXME: reference count */
|
||||||
|
|
||||||
|
setup->fs.jit_function = fs->current->jit_function;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
lp_setup_set_fs_constants(struct setup_context *setup,
|
||||||
|
struct pipe_buffer *buffer)
|
||||||
|
{
|
||||||
|
const void *data = buffer ? llvmpipe_buffer(buffer)->data : NULL;
|
||||||
|
struct pipe_buffer *dummy;
|
||||||
|
|
||||||
|
/* FIXME: hold on to the reference */
|
||||||
|
dummy = NULL;
|
||||||
|
pipe_buffer_reference(&dummy, buffer);
|
||||||
|
|
||||||
|
setup->fs.jit_context.constants = data;
|
||||||
|
|
||||||
|
setup->fs.jit_context_dirty = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
lp_setup_set_alpha_ref_value( struct setup_context *setup,
|
||||||
|
float alpha_ref_value )
|
||||||
|
{
|
||||||
|
if(setup->fs.jit_context.alpha_ref_value != alpha_ref_value) {
|
||||||
|
setup->fs.jit_context.alpha_ref_value = alpha_ref_value;
|
||||||
|
setup->fs.jit_context_dirty = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
lp_setup_set_blend_color( struct setup_context *setup,
|
||||||
|
const struct pipe_blend_color *blend_color )
|
||||||
|
{
|
||||||
|
unsigned i, j;
|
||||||
|
|
||||||
|
if(!setup->fs.jit_context.blend_color)
|
||||||
|
setup->fs.jit_context.blend_color = align_malloc(4 * 16, 16);
|
||||||
|
|
||||||
|
for (i = 0; i < 4; ++i) {
|
||||||
|
uint8_t c = float_to_ubyte(blend_color->color[i]);
|
||||||
|
for (j = 0; j < 16; ++j)
|
||||||
|
setup->fs.jit_context.blend_color[i*4 + j] = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
setup->fs.jit_context_dirty = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
lp_setup_set_sampler_textures( struct setup_context *setup,
|
||||||
|
unsigned num, struct pipe_texture **texture)
|
||||||
|
{
|
||||||
|
struct pipe_texture *dummy;
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
assert(num <= PIPE_MAX_SAMPLERS);
|
||||||
|
|
||||||
|
for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
|
||||||
|
struct pipe_texture *tex = i < num ? texture[i] : NULL;
|
||||||
|
|
||||||
|
/* FIXME: hold on to the reference */
|
||||||
|
dummy = NULL;
|
||||||
|
pipe_texture_reference(&dummy, tex);
|
||||||
|
|
||||||
|
if(tex) {
|
||||||
|
struct llvmpipe_texture *lp_tex = llvmpipe_texture(tex);
|
||||||
|
struct lp_jit_texture *jit_tex = &setup->fs.jit_context.textures[i];
|
||||||
|
jit_tex->width = tex->width[0];
|
||||||
|
jit_tex->height = tex->height[0];
|
||||||
|
jit_tex->stride = lp_tex->stride[0];
|
||||||
|
if(!lp_tex->dt)
|
||||||
|
jit_tex->data = lp_tex->data;
|
||||||
|
else
|
||||||
|
/* FIXME: map the rendertarget */
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setup->fs.jit_context_dirty = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
lp_setup_set_shader_state( struct setup_context *setup,
|
lp_setup_set_shader_state( struct setup_context *setup,
|
||||||
const struct lp_jit_context *jc )
|
const struct lp_jit_context *jc )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Stubs for lines & points for now:
|
/* Stubs for lines & points for now:
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
|
|
|
@ -50,7 +50,9 @@ struct lp_shader_input {
|
||||||
|
|
||||||
struct pipe_texture;
|
struct pipe_texture;
|
||||||
struct pipe_surface;
|
struct pipe_surface;
|
||||||
|
struct pipe_blend_color;
|
||||||
struct setup_context;
|
struct setup_context;
|
||||||
|
struct lp_fragment_shader;
|
||||||
struct lp_jit_context;
|
struct lp_jit_context;
|
||||||
|
|
||||||
struct setup_context *
|
struct setup_context *
|
||||||
|
@ -100,8 +102,25 @@ lp_setup_set_fs_inputs( struct setup_context *setup,
|
||||||
unsigned nr );
|
unsigned nr );
|
||||||
|
|
||||||
void
|
void
|
||||||
lp_setup_set_shader_state( struct setup_context *setup,
|
lp_setup_set_fs( struct setup_context *setup,
|
||||||
const struct lp_jit_context *jc );
|
struct lp_fragment_shader *fs );
|
||||||
|
|
||||||
|
void
|
||||||
|
lp_setup_set_fs_constants(struct setup_context *setup,
|
||||||
|
struct pipe_buffer *buffer);
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
lp_setup_set_alpha_ref_value( struct setup_context *setup,
|
||||||
|
float alpha_ref_value );
|
||||||
|
|
||||||
|
void
|
||||||
|
lp_setup_set_blend_color( struct setup_context *setup,
|
||||||
|
const struct pipe_blend_color *blend_color );
|
||||||
|
|
||||||
|
void
|
||||||
|
lp_setup_set_sampler_textures( struct setup_context *setup,
|
||||||
|
unsigned num, struct pipe_texture **texture);
|
||||||
|
|
||||||
boolean
|
boolean
|
||||||
lp_setup_is_texture_referenced( struct setup_context *setup,
|
lp_setup_is_texture_referenced( struct setup_context *setup,
|
||||||
|
|
|
@ -109,6 +109,11 @@ struct setup_context {
|
||||||
struct {
|
struct {
|
||||||
struct lp_shader_input input[PIPE_MAX_ATTRIBS];
|
struct lp_shader_input input[PIPE_MAX_ATTRIBS];
|
||||||
unsigned nr_inputs;
|
unsigned nr_inputs;
|
||||||
|
|
||||||
|
struct lp_jit_context jit_context;
|
||||||
|
lp_jit_frag_func jit_function;
|
||||||
|
|
||||||
|
boolean jit_context_dirty;
|
||||||
} fs;
|
} fs;
|
||||||
|
|
||||||
void (*point)( struct setup_context *,
|
void (*point)( struct setup_context *,
|
||||||
|
|
|
@ -54,6 +54,7 @@
|
||||||
#define LP_NEW_VERTEX 0x1000
|
#define LP_NEW_VERTEX 0x1000
|
||||||
#define LP_NEW_VS 0x2000
|
#define LP_NEW_VS 0x2000
|
||||||
#define LP_NEW_QUERY 0x4000
|
#define LP_NEW_QUERY 0x4000
|
||||||
|
#define LP_NEW_BLEND_COLOR 0x8000
|
||||||
|
|
||||||
|
|
||||||
struct tgsi_sampler;
|
struct tgsi_sampler;
|
||||||
|
|
|
@ -67,17 +67,16 @@ void llvmpipe_set_blend_color( struct pipe_context *pipe,
|
||||||
const struct pipe_blend_color *blend_color )
|
const struct pipe_blend_color *blend_color )
|
||||||
{
|
{
|
||||||
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
|
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
|
||||||
unsigned i, j;
|
|
||||||
|
if(!blend_color)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(memcmp(&llvmpipe->blend_color, blend_color, sizeof *blend_color) == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
memcpy(&llvmpipe->blend_color, blend_color, sizeof *blend_color);
|
memcpy(&llvmpipe->blend_color, blend_color, sizeof *blend_color);
|
||||||
|
|
||||||
if(!llvmpipe->jit_context.blend_color)
|
llvmpipe->dirty |= LP_NEW_BLEND_COLOR;
|
||||||
llvmpipe->jit_context.blend_color = align_malloc(4 * 16, 16);
|
|
||||||
for (i = 0; i < 4; ++i) {
|
|
||||||
uint8_t c = float_to_ubyte(blend_color->color[i]);
|
|
||||||
for (j = 0; j < 16; ++j)
|
|
||||||
llvmpipe->jit_context.blend_color[i*4 + j] = c;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,9 +100,6 @@ llvmpipe_bind_depth_stencil_state(struct pipe_context *pipe,
|
||||||
|
|
||||||
llvmpipe->depth_stencil = (const struct pipe_depth_stencil_alpha_state *)depth_stencil;
|
llvmpipe->depth_stencil = (const struct pipe_depth_stencil_alpha_state *)depth_stencil;
|
||||||
|
|
||||||
if(llvmpipe->depth_stencil)
|
|
||||||
llvmpipe->jit_context.alpha_ref_value = llvmpipe->depth_stencil->alpha.ref_value;
|
|
||||||
|
|
||||||
llvmpipe->dirty |= LP_NEW_DEPTH_STENCIL_ALPHA;
|
llvmpipe->dirty |= LP_NEW_DEPTH_STENCIL_ALPHA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "draw/draw_private.h"
|
#include "draw/draw_private.h"
|
||||||
#include "lp_context.h"
|
#include "lp_context.h"
|
||||||
#include "lp_screen.h"
|
#include "lp_screen.h"
|
||||||
|
#include "lp_setup.h"
|
||||||
#include "lp_state.h"
|
#include "lp_state.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -256,6 +257,23 @@ void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe )
|
||||||
LP_NEW_TEXTURE))
|
LP_NEW_TEXTURE))
|
||||||
llvmpipe_update_fs( llvmpipe );
|
llvmpipe_update_fs( llvmpipe );
|
||||||
|
|
||||||
|
if (llvmpipe->dirty & (LP_NEW_BLEND |
|
||||||
|
LP_NEW_DEPTH_STENCIL_ALPHA |
|
||||||
|
LP_NEW_SAMPLER |
|
||||||
|
LP_NEW_TEXTURE))
|
||||||
|
llvmpipe_update_fs( llvmpipe );
|
||||||
|
|
||||||
|
if (llvmpipe->dirty & LP_NEW_BLEND_COLOR)
|
||||||
|
lp_setup_set_blend_color(llvmpipe->setup, &llvmpipe->blend_color);
|
||||||
|
|
||||||
|
if (llvmpipe->dirty & LP_NEW_DEPTH_STENCIL_ALPHA)
|
||||||
|
lp_setup_set_alpha_ref_value(llvmpipe->setup, llvmpipe->depth_stencil->alpha.ref_value);
|
||||||
|
|
||||||
|
if (llvmpipe->dirty & LP_NEW_CONSTANTS)
|
||||||
|
lp_setup_set_fs_constants(llvmpipe->setup, llvmpipe->constants[PIPE_SHADER_FRAGMENT].buffer);
|
||||||
|
|
||||||
|
if (llvmpipe->dirty & LP_NEW_TEXTURE)
|
||||||
|
lp_setup_set_sampler_textures(llvmpipe->setup, llvmpipe->num_textures, llvmpipe->texture);
|
||||||
|
|
||||||
llvmpipe->dirty = 0;
|
llvmpipe->dirty = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -681,16 +681,15 @@ llvmpipe_set_constant_buffer(struct pipe_context *pipe,
|
||||||
assert(shader < PIPE_SHADER_TYPES);
|
assert(shader < PIPE_SHADER_TYPES);
|
||||||
assert(index == 0);
|
assert(index == 0);
|
||||||
|
|
||||||
|
if(llvmpipe->constants[shader].buffer == buffer)
|
||||||
|
return;
|
||||||
|
|
||||||
if(shader == PIPE_SHADER_VERTEX)
|
if(shader == PIPE_SHADER_VERTEX)
|
||||||
draw_flush(llvmpipe->draw);
|
draw_flush(llvmpipe->draw);
|
||||||
|
|
||||||
/* note: reference counting */
|
/* note: reference counting */
|
||||||
pipe_buffer_reference(&llvmpipe->constants[shader].buffer, buffer);
|
pipe_buffer_reference(&llvmpipe->constants[shader].buffer, buffer);
|
||||||
|
|
||||||
if(shader == PIPE_SHADER_FRAGMENT) {
|
|
||||||
llvmpipe->jit_context.constants = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(shader == PIPE_SHADER_VERTEX) {
|
if(shader == PIPE_SHADER_VERTEX) {
|
||||||
draw_set_mapped_constant_buffer(llvmpipe->draw, data, size);
|
draw_set_mapped_constant_buffer(llvmpipe->draw, data, size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,16 +96,6 @@ llvmpipe_set_sampler_textures(struct pipe_context *pipe,
|
||||||
struct pipe_texture *tex = i < num ? texture[i] : NULL;
|
struct pipe_texture *tex = i < num ? texture[i] : NULL;
|
||||||
|
|
||||||
pipe_texture_reference(&llvmpipe->texture[i], tex);
|
pipe_texture_reference(&llvmpipe->texture[i], tex);
|
||||||
|
|
||||||
if(tex) {
|
|
||||||
struct llvmpipe_texture *lp_tex = llvmpipe_texture(tex);
|
|
||||||
struct lp_jit_texture *jit_tex = &llvmpipe->jit_context.textures[i];
|
|
||||||
jit_tex->width = tex->width[0];
|
|
||||||
jit_tex->height = tex->height[0];
|
|
||||||
jit_tex->stride = lp_tex->stride[0];
|
|
||||||
if(!lp_tex->dt)
|
|
||||||
jit_tex->data = lp_tex->data;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
llvmpipe->num_textures = num;
|
llvmpipe->num_textures = num;
|
||||||
|
|
Loading…
Reference in New Issue