소스 검색

st/xorg: setup constant buffers for vertex and fragment shaders

tags/mesa_7_6_rc1
Zack Rusin 16 년 전
부모
커밋
9ccbadb22d
1개의 변경된 파일57개의 추가작업 그리고 17개의 파일을 삭제
  1. 57
    17
      src/gallium/state_trackers/xorg/xorg_composite.c

+ 57
- 17
src/gallium/state_trackers/xorg/xorg_composite.c 파일 보기

@@ -172,27 +172,10 @@ set_viewport(struct exa_context *exa, int width, int height,
static void
bind_viewport_state(struct exa_context *exa, PicturePtr pDstPicture)
{
const int param_bytes = 8 * sizeof(float);
int width = pDstPicture->pDrawable->width;
int height = pDstPicture->pDrawable->height;
float vs_consts[8] = {
2.f/width, 2.f/height, 1, 1,
-1, -1, 0, 0
};
struct pipe_constant_buffer *cbuf = &exa->vs_const_buffer;

set_viewport(exa, width, height, Y0_BOTTOM);

pipe_buffer_reference(&cbuf->buffer, NULL);
cbuf->buffer = pipe_buffer_create(exa->ctx->screen, 16,
PIPE_BUFFER_USAGE_CONSTANT,
param_bytes);

if (cbuf->buffer) {
pipe_buffer_write(exa->ctx->screen, cbuf->buffer,
0, param_bytes, vs_consts);
}
exa->ctx->set_constant_buffer(exa->ctx, PIPE_SHADER_VERTEX, 0, cbuf);
}

static void
@@ -295,6 +278,61 @@ bind_samplers(struct exa_context *exa, int op,
cso_set_sampler_textures(exa->cso, 3, textures);
}

static void
setup_vs_constant_buffer(struct exa_context *exa,
int width, int height)
{
const int param_bytes = 8 * sizeof(float);
float vs_consts[8] = {
2.f/width, 2.f/height, 1, 1,
-1, -1, 0, 0
};
struct pipe_constant_buffer *cbuf = &exa->vs_const_buffer;

pipe_buffer_reference(&cbuf->buffer, NULL);
cbuf->buffer = pipe_buffer_create(exa->ctx->screen, 16,
PIPE_BUFFER_USAGE_CONSTANT,
param_bytes);

if (cbuf->buffer) {
pipe_buffer_write(exa->ctx->screen, cbuf->buffer,
0, param_bytes, vs_consts);
}
exa->ctx->set_constant_buffer(exa->ctx, PIPE_SHADER_VERTEX, 0, cbuf);
}


static void
setup_fs_constant_buffer(struct exa_context *exa)
{
const int param_bytes = 4 * sizeof(float);
float fs_consts[8] = {
0, 0, 0, 1,
};
struct pipe_constant_buffer *cbuf = &exa->fs_const_buffer;

pipe_buffer_reference(&cbuf->buffer, NULL);
cbuf->buffer = pipe_buffer_create(exa->ctx->screen, 16,
PIPE_BUFFER_USAGE_CONSTANT,
param_bytes);

if (cbuf->buffer) {
pipe_buffer_write(exa->ctx->screen, cbuf->buffer,
0, param_bytes, fs_consts);
}
exa->ctx->set_constant_buffer(exa->ctx, PIPE_SHADER_FRAGMENT, 0, cbuf);
}

static void
setup_constant_buffers(struct exa_context *exa, PicturePtr pDstPicture)
{
int width = pDstPicture->pDrawable->width;
int height = pDstPicture->pDrawable->height;

setup_vs_constant_buffer(exa, width, height);
setup_fs_constant_buffer(exa);
}

boolean xorg_composite_bind_state(struct exa_context *exa,
int op,
PicturePtr pSrcPicture,
@@ -312,6 +350,8 @@ boolean xorg_composite_bind_state(struct exa_context *exa,
bind_samplers(exa, op, pSrcPicture, pMaskPicture, pDstPicture,
pSrc, pMask, pDst);

setup_constant_buffers(exa, pDstPicture);

return FALSE;
}


Loading…
취소
저장