Track fragment and vertex shader code generation via pipe shader state objects.
Unfortunately, the generated fragment shader code is effectively unusable until it handles quad->mask.
This commit is contained in:
@@ -124,9 +124,6 @@ struct draw_stage
|
|||||||
*/
|
*/
|
||||||
struct draw_vertex_shader {
|
struct draw_vertex_shader {
|
||||||
const struct pipe_shader_state *state;
|
const struct pipe_shader_state *state;
|
||||||
#if defined(__i386__) || defined(__386__)
|
|
||||||
struct x86_function sse2_program;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -214,12 +214,13 @@ draw_create_vertex_shader(struct draw_context *draw,
|
|||||||
|
|
||||||
vs->state = shader;
|
vs->state = shader;
|
||||||
#if defined(__i386__) || defined(__386__)
|
#if defined(__i386__) || defined(__386__)
|
||||||
x86_init_func(&vs->sse2_program);
|
|
||||||
|
|
||||||
if (draw->use_sse) {
|
if (draw->use_sse) {
|
||||||
tgsi_emit_sse2(shader->tokens, &vs->sse2_program);
|
x86_init_func( &shader->sse2_program );
|
||||||
((struct pipe_shader_state*)(vs->state))->executable =
|
|
||||||
x86_get_func(&vs->sse2_program);
|
tgsi_emit_sse2( shader->tokens, &shader->sse2_program );
|
||||||
|
|
||||||
|
((struct pipe_shader_state *)shader)->executable = (void *)
|
||||||
|
x86_get_func( &shader->sse2_program );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -243,9 +244,12 @@ void draw_delete_vertex_shader(struct draw_context *draw,
|
|||||||
void *vcso)
|
void *vcso)
|
||||||
{
|
{
|
||||||
struct draw_vertex_shader *vs = (struct draw_vertex_shader*)(vcso);
|
struct draw_vertex_shader *vs = (struct draw_vertex_shader*)(vcso);
|
||||||
|
|
||||||
#if defined(__i386__) || defined(__386__)
|
#if defined(__i386__) || defined(__386__)
|
||||||
x86_release_func(&vs->sse2_program);
|
x86_release_func(&vs->state->sse2_program);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
free(vs->state);
|
||||||
free(vcso);
|
free(vcso);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -40,6 +40,8 @@
|
|||||||
|
|
||||||
#include "p_compiler.h"
|
#include "p_compiler.h"
|
||||||
|
|
||||||
|
#include "x86/rtasm/x86sse.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation limits
|
* Implementation limits
|
||||||
*/
|
*/
|
||||||
@@ -143,6 +145,9 @@ struct pipe_constant_buffer {
|
|||||||
|
|
||||||
struct pipe_shader_state {
|
struct pipe_shader_state {
|
||||||
const struct tgsi_token *tokens;
|
const struct tgsi_token *tokens;
|
||||||
|
#if defined(__i386__) || defined(__386__)
|
||||||
|
struct x86_function sse2_program;
|
||||||
|
#endif
|
||||||
void *executable;
|
void *executable;
|
||||||
|
|
||||||
/** These fields somewhat constitute the shader "signature" */
|
/** These fields somewhat constitute the shader "signature" */
|
||||||
|
@@ -249,6 +249,12 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
|
|||||||
{
|
{
|
||||||
struct softpipe_context *softpipe = CALLOC_STRUCT(softpipe_context);
|
struct softpipe_context *softpipe = CALLOC_STRUCT(softpipe_context);
|
||||||
|
|
||||||
|
#if defined(__i386__) || defined(__386__)
|
||||||
|
softpipe->use_sse = getenv("GALLIUM_SSE") != NULL;
|
||||||
|
#else
|
||||||
|
softpipe->use_sse = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
softpipe->pipe.winsys = pipe_winsys;
|
softpipe->pipe.winsys = pipe_winsys;
|
||||||
softpipe->pipe.destroy = softpipe_destroy;
|
softpipe->pipe.destroy = softpipe_destroy;
|
||||||
|
|
||||||
|
@@ -154,6 +154,8 @@ struct softpipe_context {
|
|||||||
struct draw_stage *vbuf;
|
struct draw_stage *vbuf;
|
||||||
|
|
||||||
struct pipe_surface *cbuf; /**< current color buffer (one of cbufs) */
|
struct pipe_surface *cbuf; /**< current color buffer (one of cbufs) */
|
||||||
|
|
||||||
|
int use_sse : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -103,7 +103,8 @@ shade_quad(
|
|||||||
machine->Inputs[0].xyzw[1].f[3] = fy + 1.0f;
|
machine->Inputs[0].xyzw[1].f[3] = fy + 1.0f;
|
||||||
|
|
||||||
/* run shader */
|
/* run shader */
|
||||||
if( softpipe->fs->executable != NULL ) {
|
/* XXX: Generated code effectively unusable until it handles quad->mask */
|
||||||
|
if( !quad->mask && softpipe->fs->executable != NULL ) {
|
||||||
codegen_function func = (codegen_function) softpipe->fs->executable;
|
codegen_function func = (codegen_function) softpipe->fs->executable;
|
||||||
func(
|
func(
|
||||||
machine->Inputs,
|
machine->Inputs,
|
||||||
|
@@ -31,17 +31,31 @@
|
|||||||
#include "pipe/p_defines.h"
|
#include "pipe/p_defines.h"
|
||||||
#include "pipe/p_winsys.h"
|
#include "pipe/p_winsys.h"
|
||||||
#include "pipe/draw/draw_context.h"
|
#include "pipe/draw/draw_context.h"
|
||||||
|
#include "pipe/tgsi/exec/tgsi_core.h"
|
||||||
|
|
||||||
|
|
||||||
void * softpipe_create_fs_state(struct pipe_context *pipe,
|
void * softpipe_create_fs_state(struct pipe_context *pipe,
|
||||||
const struct pipe_shader_state *templ)
|
const struct pipe_shader_state *templ)
|
||||||
{
|
{
|
||||||
|
struct softpipe_context *softpipe = softpipe_context(pipe);
|
||||||
|
|
||||||
/* Decide whether we'll be codegenerating this shader and if so do
|
/* Decide whether we'll be codegenerating this shader and if so do
|
||||||
* that now.
|
* that now.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct pipe_shader_state *state = malloc(sizeof(struct pipe_shader_state));
|
struct pipe_shader_state *state = malloc(sizeof(struct pipe_shader_state));
|
||||||
memcpy(state, templ, sizeof(struct pipe_shader_state));
|
memcpy(state, templ, sizeof(struct pipe_shader_state));
|
||||||
|
|
||||||
|
#if defined(__i386__) || defined(__386__)
|
||||||
|
if (softpipe->use_sse) {
|
||||||
|
x86_init_func( &state->sse2_program );
|
||||||
|
|
||||||
|
tgsi_emit_sse2_fs( state->tokens, &state->sse2_program );
|
||||||
|
|
||||||
|
state->executable = (void *)x86_get_func( &state->sse2_program );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,6 +71,12 @@ void softpipe_bind_fs_state(struct pipe_context *pipe, void *fs)
|
|||||||
void softpipe_delete_fs_state(struct pipe_context *pipe,
|
void softpipe_delete_fs_state(struct pipe_context *pipe,
|
||||||
void *shader)
|
void *shader)
|
||||||
{
|
{
|
||||||
|
#if defined(__i386__) || defined(__386__)
|
||||||
|
struct pipe_shader_state *state = shader;
|
||||||
|
|
||||||
|
x86_release_func( &state->sse2_program );
|
||||||
|
#endif
|
||||||
|
|
||||||
free(shader);
|
free(shader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -108,10 +108,6 @@ static struct gl_program *st_new_program( GLcontext *ctx,
|
|||||||
|
|
||||||
prog->serialNo = 1;
|
prog->serialNo = 1;
|
||||||
|
|
||||||
#if defined(__i386__) || defined(__386__)
|
|
||||||
x86_init_func( &prog->sse2_program );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return _mesa_init_fragment_program( ctx,
|
return _mesa_init_fragment_program( ctx,
|
||||||
&prog->Base,
|
&prog->Base,
|
||||||
target,
|
target,
|
||||||
@@ -140,9 +136,6 @@ static void st_delete_program( GLcontext *ctx,
|
|||||||
{
|
{
|
||||||
struct st_fragment_program *stfp
|
struct st_fragment_program *stfp
|
||||||
= (struct st_fragment_program *) prog;
|
= (struct st_fragment_program *) prog;
|
||||||
#if defined(__i386__) || defined(__386__)
|
|
||||||
x86_release_func( &stfp->sse2_program );
|
|
||||||
#endif
|
|
||||||
st_remove_fragment_program(st, stfp);
|
st_remove_fragment_program(st, stfp);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@@ -390,16 +390,6 @@ st_translate_fragment_program(struct st_context *st,
|
|||||||
if (TGSI_DEBUG)
|
if (TGSI_DEBUG)
|
||||||
tgsi_dump( tokensOut, 0/*TGSI_DUMP_VERBOSE*/ );
|
tgsi_dump( tokensOut, 0/*TGSI_DUMP_VERBOSE*/ );
|
||||||
|
|
||||||
#if defined(__i386__) || defined(__386__)
|
|
||||||
if (draw_use_sse(st->draw)) {
|
|
||||||
if (stfp->sse2_program.csr == stfp->sse2_program.store)
|
|
||||||
tgsi_emit_sse2_fs( tokensOut, &stfp->sse2_program );
|
|
||||||
|
|
||||||
if (!cso->state.executable)
|
|
||||||
((struct cso_fragment_shader*)cso)->state.executable = (void *) x86_get_func( &stfp->sse2_program );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return cso;
|
return cso;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -61,10 +61,6 @@ struct st_fragment_program
|
|||||||
/** The program in TGSI format */
|
/** The program in TGSI format */
|
||||||
struct tgsi_token tokens[ST_MAX_SHADER_TOKENS];
|
struct tgsi_token tokens[ST_MAX_SHADER_TOKENS];
|
||||||
|
|
||||||
#if defined(__i386__) || defined(__386__)
|
|
||||||
struct x86_function sse2_program;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Pointer to the corresponding cached shader */
|
/** Pointer to the corresponding cached shader */
|
||||||
const struct cso_fragment_shader *fs;
|
const struct cso_fragment_shader *fs;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user