static int vlCreateVertexShaderIMC(struct VL_CONTEXT *context)
{
const unsigned int max_tokens = 50;
- const unsigned int num_attribs = 4;
- const unsigned int semantic_names[4] =
+ const unsigned int num_attribs = 3;
+ const unsigned int semantic_names[3] =
{
TGSI_SEMANTIC_POSITION,
TGSI_SEMANTIC_GENERIC,
TGSI_SEMANTIC_GENERIC,
- TGSI_SEMANTIC_GENERIC
};
- const unsigned int semantic_indexes[4] = {0, 1, 2, 3};
+ const unsigned int semantic_indexes[3] = {0, 1, 2};
const unsigned int proc_type = TGSI_PROCESSOR_VERTEX;
struct pipe_context *pipe;
/*
mov o1, i1 ; Move texcoords to output
mov o2, i2
- mov o3, i3
*/
for (i = 1; i < num_attribs; ++i)
{
ti = 3;
/* Declare inputs (texcoords) */
- for (i = 0; i < 3; ++i)
+ for (i = 0; i < 2; ++i)
{
decl = tgsi_default_full_declaration();
decl.Declaration.File = TGSI_FILE_INPUT;
/*
tex2d o0.x, i0, s0 ; Read texel from luma texture into .x channel
tex2d o0.y, i1, s1 ; Read texel from chroma Cb texture into .y channel
- tex2d o0.z, i2, s2 ; Read texel from chroma Cr texture into .z channel
+ tex2d o0.z, i1, s2 ; Read texel from chroma Cr texture into .z channel
*/
for (i = 0; i < 3; ++i)
{
inst.Instruction.NumSrcRegs = 2;
inst.InstructionExtTexture.Texture = TGSI_TEXTURE_2D;
inst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_INPUT;
- inst.FullSrcRegisters[0].SrcRegister.Index = i;
+ inst.FullSrcRegisters[0].SrcRegister.Index = i > 0 ? 1 : 0;
inst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_SAMPLER;
inst.FullSrcRegisters[1].SrcRegister.Index = i;
ti += tgsi_build_full_instruction
static int vlCreateVertexShaderPMC(struct VL_CONTEXT *context)
{
const unsigned int max_tokens = 100;
- const unsigned int num_attribs = 5;
- const unsigned int semantic_names[5] =
+ const unsigned int num_input_attribs = 3;
+ const unsigned int num_output_attribs = 4;
+ const unsigned int input_semantic_names[3] =
{
TGSI_SEMANTIC_POSITION,
TGSI_SEMANTIC_GENERIC,
+ TGSI_SEMANTIC_GENERIC
+ };
+ const unsigned int output_semantic_names[4] =
+ {
+ TGSI_SEMANTIC_POSITION,
TGSI_SEMANTIC_GENERIC,
TGSI_SEMANTIC_GENERIC,
TGSI_SEMANTIC_GENERIC
};
- const unsigned int semantic_indexes[5] = {0, 1, 2, 3, 4};
+ const unsigned int input_semantic_indexes[3] = {0, 1, 2};
+ const unsigned int output_semantic_indexes[4] = {0, 1, 2, 3};
const unsigned int proc_type = TGSI_PROCESSOR_VERTEX;
struct pipe_context *pipe;
ti = 3;
/* Declare inputs (pos, texcoords) */
- for (i = 0; i < num_attribs; i++)
+ for (i = 0; i < num_input_attribs; i++)
{
decl = tgsi_default_full_declaration();
decl.Declaration.File = TGSI_FILE_INPUT;
decl.Declaration.Semantic = 1;
- decl.Semantic.SemanticName = semantic_names[i];
- decl.Semantic.SemanticIndex = semantic_indexes[i];
+ decl.Semantic.SemanticName = input_semantic_names[i];
+ decl.Semantic.SemanticIndex = input_semantic_indexes[i];
decl.u.DeclarationRange.First = i;
decl.u.DeclarationRange.Last = i;
);
/* Declare outputs (pos, texcoords) */
- for (i = 0; i < num_attribs; i++)
+ for (i = 0; i < num_output_attribs; i++)
{
decl = tgsi_default_full_declaration();
decl.Declaration.File = TGSI_FILE_OUTPUT;
decl.Declaration.Semantic = 1;
- decl.Semantic.SemanticName = semantic_names[i];
- decl.Semantic.SemanticIndex = semantic_indexes[i];
+ decl.Semantic.SemanticName = output_semantic_names[i];
+ decl.Semantic.SemanticIndex = output_semantic_indexes[i];
decl.u.DeclarationRange.First = i;
decl.u.DeclarationRange.Last = i;
ti += tgsi_build_full_declaration
/*
mov o1, i1 ; Move luma & chroma texcoords to output
mov o2, i2
- mov o3, i3
*/
- for (i = 1; i < num_attribs - 1; ++i)
+ for (i = 1; i < num_output_attribs - 1; ++i)
{
inst = tgsi_default_full_instruction();
inst.Instruction.Opcode = TGSI_OPCODE_MOV;
max_tokens - ti
);
}
-
- /* mul t0, i4, c0 ; Scale normalized coords to window coords */
- inst = tgsi_default_full_instruction();
- inst.Instruction.Opcode = TGSI_OPCODE_MUL;
- inst.Instruction.NumDstRegs = 1;
- inst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
- inst.FullDstRegisters[0].DstRegister.Index = 0;
- inst.Instruction.NumSrcRegs = 2;
- inst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_INPUT;
- inst.FullSrcRegisters[0].SrcRegister.Index = 4;
- inst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_CONSTANT;
- inst.FullSrcRegisters[1].SrcRegister.Index = 0;
- ti += tgsi_build_full_instruction
- (
- &inst,
- &tokens[ti],
- header,
- max_tokens - ti
- );
- /* add o4, t0, c2 ; Translate texcoords into position */
+ /* add o3, t0, c2 ; Translate texcoords into position */
inst = tgsi_default_full_instruction();
inst.Instruction.Opcode = TGSI_OPCODE_ADD;
inst.Instruction.NumDstRegs = 1;
inst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_OUTPUT;
- inst.FullDstRegisters[0].DstRegister.Index = 4;
+ inst.FullDstRegisters[0].DstRegister.Index = 3;
inst.Instruction.NumSrcRegs = 2;
inst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
inst.FullSrcRegisters[0].SrcRegister.Index = 0;
ti = 3;
/* Declare inputs (texcoords) */
- for (i = 0; i < 4; ++i)
+ for (i = 0; i < 3; ++i)
{
decl = tgsi_default_full_declaration();
decl.Declaration.File = TGSI_FILE_INPUT;
mov t1.x, t0.w ; Move high part from .w channel to .x
tex2d t0.yw, i1, s1 ; Read texel from chroma Cb texture into .y and .w channels
mov t1.y, t0.w ; Move high part from .w channel to .y
- tex2d t0.zw, i2, s2 ; Read texel from chroma Cr texture into .z and .w channels
+ tex2d t0.zw, i1, s2 ; Read texel from chroma Cr texture into .z and .w channels
mov t1.z, t0.w ; Move high part from .w channel to .z
*/
for (i = 0; i < 3; ++i)
inst.Instruction.NumSrcRegs = 2;
inst.InstructionExtTexture.Texture = TGSI_TEXTURE_2D;
inst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_INPUT;
- inst.FullSrcRegisters[0].SrcRegister.Index = i;
+ inst.FullSrcRegisters[0].SrcRegister.Index = i > 0 ? 1 : 0;
inst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_SAMPLER;
inst.FullSrcRegisters[1].SrcRegister.Index = i;
ti += tgsi_build_full_instruction
max_tokens - ti
);
- /* tex2d t1, i3, s3 ; Read texel from ref macroblock */
+ /* tex2d t1, i2, s3 ; Read texel from ref macroblock */
inst = tgsi_default_full_instruction();
inst.Instruction.Opcode = TGSI_OPCODE_TEX;
inst.Instruction.NumDstRegs = 1;
inst.Instruction.NumSrcRegs = 2;
inst.InstructionExtTexture.Texture = TGSI_TEXTURE_2D;
inst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_INPUT;
- inst.FullSrcRegisters[0].SrcRegister.Index = 3;
+ inst.FullSrcRegisters[0].SrcRegister.Index = 2;
inst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_SAMPLER;
inst.FullSrcRegisters[1].SrcRegister.Index = 3;
ti += tgsi_build_full_instruction
static int vlCreateVertexShaderBMC(struct VL_CONTEXT *context)
{
const unsigned int max_tokens = 100;
- const unsigned int num_attribs = 6;
- const unsigned int semantic_names[6] =
+ const unsigned int num_input_attribs = 3;
+ const unsigned int num_output_attribs = 5;
+ const unsigned int input_semantic_names[3] =
{
TGSI_SEMANTIC_POSITION,
TGSI_SEMANTIC_GENERIC,
+ TGSI_SEMANTIC_GENERIC
+ };
+ const unsigned int output_semantic_names[5] =
+ {
+ TGSI_SEMANTIC_POSITION,
TGSI_SEMANTIC_GENERIC,
TGSI_SEMANTIC_GENERIC,
TGSI_SEMANTIC_GENERIC,
TGSI_SEMANTIC_GENERIC
};
- const unsigned int semantic_indexes[6] = {0, 1, 2, 3, 4, 5};
+ const unsigned int input_semantic_indexes[3] = {0, 1, 2};
+ const unsigned int output_semantic_indexes[5] = {0, 1, 2, 3, 4};
const unsigned int proc_type = TGSI_PROCESSOR_VERTEX;
struct pipe_context *pipe;
ti = 3;
/* Declare inputs (pos, texcoords) */
- for (i = 0; i < num_attribs; i++)
+ for (i = 0; i < num_input_attribs; i++)
{
decl = tgsi_default_full_declaration();
decl.Declaration.File = TGSI_FILE_INPUT;
decl.Declaration.Semantic = 1;
- decl.Semantic.SemanticName = semantic_names[i];
- decl.Semantic.SemanticIndex = semantic_indexes[i];
+ decl.Semantic.SemanticName = input_semantic_names[i];
+ decl.Semantic.SemanticIndex = input_semantic_indexes[i];
decl.u.DeclarationRange.First = i;
decl.u.DeclarationRange.Last = i;
);
/* Declare outputs (pos, texcoords) */
- for (i = 0; i < num_attribs; i++)
+ for (i = 0; i < num_output_attribs; i++)
{
decl = tgsi_default_full_declaration();
decl.Declaration.File = TGSI_FILE_OUTPUT;
decl.Declaration.Semantic = 1;
- decl.Semantic.SemanticName = semantic_names[i];
- decl.Semantic.SemanticIndex = semantic_indexes[i];
+ decl.Semantic.SemanticName = output_semantic_names[i];
+ decl.Semantic.SemanticIndex = output_semantic_indexes[i];
decl.u.DeclarationRange.First = i;
decl.u.DeclarationRange.Last = i;
ti += tgsi_build_full_declaration
/*
mov o1, i1 ; Move luma & chroma texcoords to output
mov o2, i2
- mov o3, i3
*/
- for (i = 1; i < num_attribs - 1; ++i)
+ for (i = 1; i < num_output_attribs - 2; ++i)
{
inst = tgsi_default_full_instruction();
inst.Instruction.Opcode = TGSI_OPCODE_MOV;
);
}
- /* mul t0, i4, c0 ; Scale normalized coords to window coords
- add o4, t0, c2 ; Translate texcoords into position
- mul t1, i5, c0 ; Repeat for the future surface
- add o5, t1, c3 */
+ /* add o3, t0, c2 ; Translate past surface texcoords into position
+ add o4, t0, c3 ; Repeat for future surface texcoords */
for (i = 0; i < 2; ++i)
{
- inst = tgsi_default_full_instruction();
- inst.Instruction.Opcode = TGSI_OPCODE_MUL;
- inst.Instruction.NumDstRegs = 1;
- inst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_TEMPORARY;
- inst.FullDstRegisters[0].DstRegister.Index = i;
- inst.Instruction.NumSrcRegs = 2;
- inst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_INPUT;
- inst.FullSrcRegisters[0].SrcRegister.Index = i + 4;
- inst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_CONSTANT;
- inst.FullSrcRegisters[1].SrcRegister.Index = 0;
- ti += tgsi_build_full_instruction
- (
- &inst,
- &tokens[ti],
- header,
- max_tokens - ti
- );
-
inst = tgsi_default_full_instruction();
inst.Instruction.Opcode = TGSI_OPCODE_ADD;
inst.Instruction.NumDstRegs = 1;
inst.FullDstRegisters[0].DstRegister.File = TGSI_FILE_OUTPUT;
- inst.FullDstRegisters[0].DstRegister.Index = i + 4;
+ inst.FullDstRegisters[0].DstRegister.Index = i + 3;
inst.Instruction.NumSrcRegs = 2;
inst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_TEMPORARY;
- inst.FullSrcRegisters[0].SrcRegister.Index = i;
+ inst.FullSrcRegisters[0].SrcRegister.Index = 0;
inst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_CONSTANT;
inst.FullSrcRegisters[1].SrcRegister.Index = i + 2;
ti += tgsi_build_full_instruction
ti = 3;
/* Declare inputs (texcoords) */
- for (i = 0; i < 5; ++i)
+ for (i = 0; i < 4; ++i)
{
decl = tgsi_default_full_declaration();
decl.Declaration.File = TGSI_FILE_INPUT;
mov t1.x, t0.w ; Move high part from .w channel to .x
tex2d t0.yw, i1, s1 ; Read texel from chroma Cb texture into .y and .w channels
mov t1.y, t0.w ; Move high part from .w channel to .y
- tex2d t0.zw, i2, s2 ; Read texel from chroma Cr texture into .z and .w channels
+ tex2d t0.zw, i1, s2 ; Read texel from chroma Cr texture into .z and .w channels
mov t1.z, t0.w ; Move high part from .w channel to .z
*/
for (i = 0; i < 3; ++i)
inst.Instruction.NumSrcRegs = 2;
inst.InstructionExtTexture.Texture = TGSI_TEXTURE_2D;
inst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_INPUT;
- inst.FullSrcRegisters[0].SrcRegister.Index = i;
+ inst.FullSrcRegisters[0].SrcRegister.Index = i > 0 ? 1 : 0;
inst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_SAMPLER;
inst.FullSrcRegisters[1].SrcRegister.Index = i;
ti += tgsi_build_full_instruction
max_tokens - ti
);
- /* tex2d t1, i3, s3 ; Read texel from past macroblock
- tex2d t2, i4, s4 ; Read texel from future macroblock */
+ /* tex2d t1, i2, s3 ; Read texel from past macroblock
+ tex2d t2, i3, s4 ; Read texel from future macroblock */
for (i = 0; i < 2; ++i)
{
inst = tgsi_default_full_instruction();
inst.Instruction.NumSrcRegs = 2;
inst.InstructionExtTexture.Texture = TGSI_TEXTURE_2D;
inst.FullSrcRegisters[0].SrcRegister.File = TGSI_FILE_INPUT;
- inst.FullSrcRegisters[0].SrcRegister.Index = i + 3;
+ inst.FullSrcRegisters[0].SrcRegister.Index = i + 2;
inst.FullSrcRegisters[1].SrcRegister.File = TGSI_FILE_SAMPLER;
inst.FullSrcRegisters[1].SrcRegister.Index = i + 3;
ti += tgsi_build_full_instruction
/* Create our texcoord buffers and texcoord buffer elements */
/* TODO: Should be able to use 1 texcoord buf for chroma textures, 1 buf for ref surfaces */
- for (i = 1; i < 6; ++i)
+ for (i = 1; i < 3; ++i)
{
context->states.mc.vertex_bufs[i].pitch = sizeof(struct VL_TEXCOORD2F);
context->states.mc.vertex_bufs[i].max_index = 23;
vl_chroma_420_texcoords,
sizeof(struct VL_TEXCOORD2F) * 24
);
- memcpy
- (
- pipe->winsys->buffer_map(pipe->winsys, context->states.mc.vertex_bufs[3].buffer, PIPE_BUFFER_USAGE_CPU_WRITE),
- vl_chroma_420_texcoords,
- sizeof(struct VL_TEXCOORD2F) * 24
- );
- memcpy
- (
- pipe->winsys->buffer_map(pipe->winsys, context->states.mc.vertex_bufs[4].buffer, PIPE_BUFFER_USAGE_CPU_WRITE),
- vl_ref_surface_texcoords,
- sizeof(struct VL_TEXCOORD2F) * 24
- );
- memcpy
- (
- pipe->winsys->buffer_map(pipe->winsys, context->states.mc.vertex_bufs[5].buffer, PIPE_BUFFER_USAGE_CPU_WRITE),
- vl_ref_surface_texcoords,
- sizeof(struct VL_TEXCOORD2F) * 24
- );
- for (i = 0; i < 6; ++i)
+ for (i = 0; i < 3; ++i)
pipe->winsys->buffer_unmap(pipe->winsys, context->states.mc.vertex_bufs[i].buffer);
/* Create our constant buffer */
assert(context);
for (i = 0; i < 5; ++i)
- {
context->pipe->delete_sampler_state(context->pipe, context->states.mc.samplers[i]);
- context->pipe->winsys->buffer_destroy(context->pipe->winsys, context->states.mc.vertex_bufs[i].buffer);
- }
- context->pipe->winsys->buffer_destroy(context->pipe->winsys, context->states.mc.vertex_bufs[5].buffer);
+ for (i = 0; i < 3; ++i)
+ context->pipe->winsys->buffer_destroy(context->pipe->winsys, context->states.mc.vertex_bufs[i].buffer);
/* Textures 3 & 4 are not created directly, no need to release them here */
for (i = 0; i < 3; ++i)
pipe = context->pipe;
/* Frame buffer set in vlRender*Macroblock() */
- /* Shaders, samplers, textures, VBs, VB elements set in vlRender*Macroblock() */
+ /* Shaders, samplers, textures set in vlRender*Macroblock() */
+ pipe->set_vertex_buffers(pipe, 3, context->states.mc.vertex_bufs);
+ pipe->set_vertex_elements(pipe, 3, context->states.mc.vertex_buf_elems);
pipe->set_viewport_state(pipe, &context->states.mc.viewport);
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, &context->states.mc.vs_const_buf);
pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, 0, &context->states.mc.fs_const_buf);