mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 05:18:08 +02:00
cell: add support for fragment shader constant buffers
This commit is contained in:
parent
ce416566bc
commit
800c350d71
7 changed files with 63 additions and 7 deletions
|
|
@ -94,6 +94,7 @@
|
|||
#define CELL_CMD_STATE_BIND_VS 18
|
||||
#define CELL_CMD_STATE_FRAGMENT_PROGRAM 19
|
||||
#define CELL_CMD_STATE_ATTRIB_FETCH 20
|
||||
#define CELL_CMD_STATE_FS_CONSTANTS 21
|
||||
#define CELL_CMD_VS_EXECUTE 22
|
||||
#define CELL_CMD_FLUSH_BUFFER_RANGE 23
|
||||
|
||||
|
|
|
|||
|
|
@ -215,7 +215,15 @@ get_src_reg(struct codegen *gen,
|
|||
reg = gen->imm_regs[src->SrcRegister.Index][swizzle];
|
||||
break;
|
||||
case TGSI_FILE_CONSTANT:
|
||||
/* xxx fall-through for now / fix */
|
||||
{
|
||||
/* offset is measured in quadwords, not bytes */
|
||||
int offset = src->SrcRegister.Index * 4 + swizzle;
|
||||
reg = get_itemp(gen);
|
||||
reg_is_itemp = TRUE;
|
||||
/* Load: reg = memory[(machine_reg) + offset] */
|
||||
spe_lqd(gen->f, reg, gen->constants_reg, offset);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,8 +44,9 @@
|
|||
#define CELL_NEW_TEXTURE 0x800
|
||||
#define CELL_NEW_VERTEX 0x1000
|
||||
#define CELL_NEW_VS 0x2000
|
||||
#define CELL_NEW_CONSTANTS 0x4000
|
||||
#define CELL_NEW_VERTEX_INFO 0x8000
|
||||
#define CELL_NEW_VS_CONSTANTS 0x4000
|
||||
#define CELL_NEW_FS_CONSTANTS 0x8000
|
||||
#define CELL_NEW_VERTEX_INFO 0x10000
|
||||
|
||||
|
||||
extern void
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include "pipe/p_inlines.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "cell_context.h"
|
||||
#include "cell_gen_fragment.h"
|
||||
|
|
@ -162,6 +163,24 @@ cell_emit_state(struct cell_context *cell)
|
|||
}
|
||||
}
|
||||
|
||||
if (cell->dirty & (CELL_NEW_FS_CONSTANTS)) {
|
||||
const uint shader = PIPE_SHADER_FRAGMENT;
|
||||
const uint num_const = cell->constants[shader].size / sizeof(float);
|
||||
uint i, j;
|
||||
float *buf = cell_batch_alloc(cell, 16 + num_const * sizeof(float));
|
||||
uint64_t *ibuf = (uint64_t *) buf;
|
||||
const float *constants = pipe_buffer_map(cell->pipe.screen,
|
||||
cell->constants[shader].buffer,
|
||||
PIPE_BUFFER_USAGE_CPU_READ);
|
||||
ibuf[0] = CELL_CMD_STATE_FS_CONSTANTS;
|
||||
ibuf[1] = num_const;
|
||||
j = 4;
|
||||
for (i = 0; i < num_const; i++) {
|
||||
buf[j++] = constants[i];
|
||||
}
|
||||
pipe_buffer_unmap(cell->pipe.screen, cell->constants[shader].buffer);
|
||||
}
|
||||
|
||||
if (cell->dirty & (CELL_NEW_FRAMEBUFFER |
|
||||
CELL_NEW_DEPTH_STENCIL |
|
||||
CELL_NEW_BLEND)) {
|
||||
|
|
|
|||
|
|
@ -197,7 +197,10 @@ cell_set_constant_buffer(struct pipe_context *pipe,
|
|||
buf->buffer);
|
||||
cell->constants[shader].size = buf->size;
|
||||
|
||||
cell->dirty |= CELL_NEW_CONSTANTS;
|
||||
if (shader == PIPE_SHADER_VERTEX)
|
||||
cell->dirty |= CELL_NEW_VS_CONSTANTS;
|
||||
else if (shader == PIPE_SHADER_FRAGMENT)
|
||||
cell->dirty |= CELL_NEW_FS_CONSTANTS;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -231,6 +231,25 @@ cmd_state_fragment_program(const struct cell_command_fragment_program *fp)
|
|||
}
|
||||
|
||||
|
||||
static uint
|
||||
cmd_state_fs_constants(const uint64_t *buffer, uint pos)
|
||||
{
|
||||
const uint num_const = buffer[pos + 1];
|
||||
const float *constants = (const float *) &buffer[pos + 2];
|
||||
uint i;
|
||||
|
||||
DEBUG_PRINTF("CMD_STATE_FS_CONSTANTS (%u)\n", num_const);
|
||||
|
||||
/* Expand each float to float[4] for SOA execution */
|
||||
for (i = 0; i < num_const; i++) {
|
||||
spu.constants[i] = spu_splats(constants[i]);
|
||||
}
|
||||
|
||||
/* return new buffer pos (in 8-byte words) */
|
||||
return pos + 2 + num_const / 2;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
cmd_state_framebuffer(const struct cell_command_framebuffer *cmd)
|
||||
{
|
||||
|
|
@ -456,6 +475,9 @@ cmd_batch(uint opcode)
|
|||
pos += sizeof(*fp) / 8;
|
||||
}
|
||||
break;
|
||||
case CELL_CMD_STATE_FS_CONSTANTS:
|
||||
pos = cmd_state_fs_constants(buffer, pos);
|
||||
break;
|
||||
case CELL_CMD_STATE_SAMPLER:
|
||||
{
|
||||
struct cell_command_sampler *sampler
|
||||
|
|
|
|||
|
|
@ -41,6 +41,9 @@
|
|||
#define MAX_HEIGHT 1024
|
||||
|
||||
|
||||
#define CELL_MAX_CONSTANTS 32 /**< number of float[4] constants */
|
||||
|
||||
|
||||
/**
|
||||
* A tile is basically a TILE_SIZE x TILE_SIZE block of 4-byte pixels.
|
||||
* The data may be addressed through several different types.
|
||||
|
|
@ -157,9 +160,8 @@ struct spu_global
|
|||
/** Current texture sampler function */
|
||||
spu_sample_texture_func sample_texture[CELL_MAX_SAMPLERS];
|
||||
|
||||
/** Fragment program constants (XXX preliminary/used) */
|
||||
#define MAX_CONSTANTS 32
|
||||
vector float constants[MAX_CONSTANTS];
|
||||
/** Fragment program constants */
|
||||
vector float constants[4 * CELL_MAX_CONSTANTS];
|
||||
|
||||
} ALIGN16_ATTRIB;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue