mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-07 23:50:11 +01:00
g3dvl: Delete state_trackers/g3dvl, other unused files.
This commit is contained in:
parent
fcb595c04f
commit
577f12fbba
23 changed files with 0 additions and 4778 deletions
|
|
@ -1,21 +0,0 @@
|
|||
TARGET = libg3dvl.a
|
||||
OBJECTS = vl_display.o vl_screen.o vl_context.o vl_surface.o vl_shader_build.o vl_util.o vl_basic_csc.o \
|
||||
vl_r16snorm_mc_buf.o
|
||||
GALLIUMDIR = ../..
|
||||
|
||||
CFLAGS += -g -Wall -Werror-implicit-function-declaration -fPIC \
|
||||
-I${GALLIUMDIR}/include \
|
||||
-I${GALLIUMDIR}/auxiliary \
|
||||
-I${GALLIUMDIR}/winsys/g3dvl \
|
||||
|
||||
#############################################
|
||||
|
||||
.PHONY = all clean
|
||||
|
||||
all: ${TARGET}
|
||||
|
||||
${TARGET}: ${OBJECTS}
|
||||
ar rcs $@ $^
|
||||
|
||||
clean:
|
||||
rm -rf ${OBJECTS} ${TARGET}
|
||||
|
|
@ -1,720 +0,0 @@
|
|||
#define VL_INTERNAL
|
||||
#include "vl_basic_csc.h"
|
||||
#include <assert.h>
|
||||
#include <pipe/p_context.h>
|
||||
#include <pipe/p_state.h>
|
||||
#include <pipe/p_inlines.h>
|
||||
#include <tgsi/tgsi_parse.h>
|
||||
#include <tgsi/tgsi_build.h>
|
||||
#include <util/u_memory.h>
|
||||
#include "vl_csc.h"
|
||||
#include "vl_surface.h"
|
||||
#include "vl_shader_build.h"
|
||||
#include "vl_types.h"
|
||||
|
||||
struct vlVertexShaderConsts
|
||||
{
|
||||
struct vlVertex4f dst_scale;
|
||||
struct vlVertex4f dst_trans;
|
||||
struct vlVertex4f src_scale;
|
||||
struct vlVertex4f src_trans;
|
||||
};
|
||||
|
||||
struct vlFragmentShaderConsts
|
||||
{
|
||||
struct vlVertex4f bias;
|
||||
float matrix[16];
|
||||
};
|
||||
|
||||
struct vlBasicCSC
|
||||
{
|
||||
struct vlCSC base;
|
||||
|
||||
struct pipe_context *pipe;
|
||||
struct pipe_viewport_state viewport;
|
||||
struct pipe_framebuffer_state framebuffer;
|
||||
struct pipe_texture *framebuffer_tex;
|
||||
void *sampler;
|
||||
void *vertex_shader, *fragment_shader;
|
||||
struct pipe_vertex_buffer vertex_bufs[2];
|
||||
struct pipe_vertex_element vertex_elems[2];
|
||||
struct pipe_constant_buffer vs_const_buf, fs_const_buf;
|
||||
};
|
||||
|
||||
static int vlResizeFrameBuffer
|
||||
(
|
||||
struct vlCSC *csc,
|
||||
unsigned int width,
|
||||
unsigned int height
|
||||
)
|
||||
{
|
||||
struct vlBasicCSC *basic_csc;
|
||||
struct pipe_context *pipe;
|
||||
struct pipe_texture template;
|
||||
float clear_color[4];
|
||||
|
||||
assert(csc);
|
||||
|
||||
basic_csc = (struct vlBasicCSC*)csc;
|
||||
pipe = basic_csc->pipe;
|
||||
|
||||
if (basic_csc->framebuffer.width == width && basic_csc->framebuffer.height == height)
|
||||
return 0;
|
||||
|
||||
basic_csc->viewport.scale[0] = width;
|
||||
basic_csc->viewport.scale[1] = height;
|
||||
basic_csc->viewport.scale[2] = 1;
|
||||
basic_csc->viewport.scale[3] = 1;
|
||||
basic_csc->viewport.translate[0] = 0;
|
||||
basic_csc->viewport.translate[1] = 0;
|
||||
basic_csc->viewport.translate[2] = 0;
|
||||
basic_csc->viewport.translate[3] = 0;
|
||||
|
||||
clear_color[0] = 0.0f;
|
||||
clear_color[1] = 0.0f;
|
||||
clear_color[2] = 0.0f;
|
||||
clear_color[3] = 0.0f;
|
||||
|
||||
if (basic_csc->framebuffer_tex)
|
||||
{
|
||||
pipe_surface_reference(&basic_csc->framebuffer.cbufs[0], NULL);
|
||||
pipe_texture_reference(&basic_csc->framebuffer_tex, NULL);
|
||||
}
|
||||
|
||||
memset(&template, 0, sizeof(struct pipe_texture));
|
||||
template.target = PIPE_TEXTURE_2D;
|
||||
template.format = PIPE_FORMAT_A8R8G8B8_UNORM;
|
||||
template.last_level = 0;
|
||||
template.width[0] = width;
|
||||
template.height[0] = height;
|
||||
template.depth[0] = 1;
|
||||
pf_get_block(template.format, &template.block);
|
||||
template.tex_usage = PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
|
||||
|
||||
basic_csc->framebuffer_tex = pipe->screen->texture_create(pipe->screen, &template);
|
||||
|
||||
basic_csc->framebuffer.width = width;
|
||||
basic_csc->framebuffer.height = height;
|
||||
basic_csc->framebuffer.cbufs[0] = pipe->screen->get_tex_surface
|
||||
(
|
||||
pipe->screen,
|
||||
basic_csc->framebuffer_tex,
|
||||
0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE
|
||||
);
|
||||
|
||||
/* Clear to black, in case video doesn't fill the entire window */
|
||||
pipe->set_framebuffer_state(pipe, &basic_csc->framebuffer);
|
||||
pipe->clear(pipe, PIPE_CLEAR_COLOR, clear_color, 0.0f, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vlBegin
|
||||
(
|
||||
struct vlCSC *csc
|
||||
)
|
||||
{
|
||||
struct vlBasicCSC *basic_csc;
|
||||
struct pipe_context *pipe;
|
||||
|
||||
assert(csc);
|
||||
|
||||
basic_csc = (struct vlBasicCSC*)csc;
|
||||
pipe = basic_csc->pipe;
|
||||
|
||||
pipe->set_framebuffer_state(pipe, &basic_csc->framebuffer);
|
||||
pipe->set_viewport_state(pipe, &basic_csc->viewport);
|
||||
pipe->bind_sampler_states(pipe, 1, (void**)&basic_csc->sampler);
|
||||
/* Source texture set in vlPutPictureCSC() */
|
||||
pipe->bind_vs_state(pipe, basic_csc->vertex_shader);
|
||||
pipe->bind_fs_state(pipe, basic_csc->fragment_shader);
|
||||
pipe->set_vertex_buffers(pipe, 2, basic_csc->vertex_bufs);
|
||||
pipe->set_vertex_elements(pipe, 2, basic_csc->vertex_elems);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, &basic_csc->vs_const_buf);
|
||||
pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, 0, &basic_csc->fs_const_buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vlPutPictureCSC
|
||||
(
|
||||
struct vlCSC *csc,
|
||||
struct vlSurface *surface,
|
||||
int srcx,
|
||||
int srcy,
|
||||
int srcw,
|
||||
int srch,
|
||||
int destx,
|
||||
int desty,
|
||||
int destw,
|
||||
int desth,
|
||||
enum vlPictureType picture_type
|
||||
)
|
||||
{
|
||||
struct vlBasicCSC *basic_csc;
|
||||
struct pipe_context *pipe;
|
||||
struct vlVertexShaderConsts *vs_consts;
|
||||
|
||||
assert(csc);
|
||||
assert(surface);
|
||||
|
||||
basic_csc = (struct vlBasicCSC*)csc;
|
||||
pipe = basic_csc->pipe;
|
||||
|
||||
vs_consts = pipe_buffer_map
|
||||
(
|
||||
pipe->screen,
|
||||
basic_csc->vs_const_buf.buffer,
|
||||
PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_DISCARD
|
||||
);
|
||||
|
||||
vs_consts->dst_scale.x = destw / (float)basic_csc->framebuffer.cbufs[0]->width;
|
||||
vs_consts->dst_scale.y = desth / (float)basic_csc->framebuffer.cbufs[0]->height;
|
||||
vs_consts->dst_scale.z = 1;
|
||||
vs_consts->dst_scale.w = 1;
|
||||
vs_consts->dst_trans.x = destx / (float)basic_csc->framebuffer.cbufs[0]->width;
|
||||
vs_consts->dst_trans.y = desty / (float)basic_csc->framebuffer.cbufs[0]->height;
|
||||
vs_consts->dst_trans.z = 0;
|
||||
vs_consts->dst_trans.w = 0;
|
||||
|
||||
vs_consts->src_scale.x = srcw / (float)surface->texture->width[0];
|
||||
vs_consts->src_scale.y = srch / (float)surface->texture->height[0];
|
||||
vs_consts->src_scale.z = 1;
|
||||
vs_consts->src_scale.w = 1;
|
||||
vs_consts->src_trans.x = srcx / (float)surface->texture->width[0];
|
||||
vs_consts->src_trans.y = srcy / (float)surface->texture->height[0];
|
||||
vs_consts->src_trans.z = 0;
|
||||
vs_consts->src_trans.w = 0;
|
||||
|
||||
pipe_buffer_unmap(pipe->screen, basic_csc->vs_const_buf.buffer);
|
||||
|
||||
pipe->set_sampler_textures(pipe, 1, &surface->texture);
|
||||
pipe->draw_arrays(pipe, PIPE_PRIM_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vlEnd
|
||||
(
|
||||
struct vlCSC *csc
|
||||
)
|
||||
{
|
||||
assert(csc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct pipe_surface* vlGetFrameBuffer
|
||||
(
|
||||
struct vlCSC *csc
|
||||
)
|
||||
{
|
||||
struct vlBasicCSC *basic_csc;
|
||||
|
||||
assert(csc);
|
||||
|
||||
basic_csc = (struct vlBasicCSC*)csc;
|
||||
|
||||
return basic_csc->framebuffer.cbufs[0];
|
||||
}
|
||||
|
||||
static int vlDestroy
|
||||
(
|
||||
struct vlCSC *csc
|
||||
)
|
||||
{
|
||||
struct vlBasicCSC *basic_csc;
|
||||
struct pipe_context *pipe;
|
||||
unsigned int i;
|
||||
|
||||
assert(csc);
|
||||
|
||||
basic_csc = (struct vlBasicCSC*)csc;
|
||||
pipe = basic_csc->pipe;
|
||||
|
||||
if (basic_csc->framebuffer_tex)
|
||||
{
|
||||
pipe_surface_reference(&basic_csc->framebuffer.cbufs[0], NULL);
|
||||
pipe_texture_reference(&basic_csc->framebuffer_tex, NULL);
|
||||
}
|
||||
|
||||
pipe->delete_sampler_state(pipe, basic_csc->sampler);
|
||||
pipe->delete_vs_state(pipe, basic_csc->vertex_shader);
|
||||
pipe->delete_fs_state(pipe, basic_csc->fragment_shader);
|
||||
|
||||
for (i = 0; i < 2; ++i)
|
||||
pipe_buffer_reference(&basic_csc->vertex_bufs[i].buffer, NULL);
|
||||
|
||||
pipe_buffer_reference(&basic_csc->vs_const_buf.buffer, NULL);
|
||||
pipe_buffer_reference(&basic_csc->fs_const_buf.buffer, NULL);
|
||||
|
||||
FREE(basic_csc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Represents 2 triangles in a strip in normalized coords.
|
||||
* Used to render the surface onto the frame buffer.
|
||||
*/
|
||||
static const struct vlVertex2f surface_verts[4] =
|
||||
{
|
||||
{0.0f, 0.0f},
|
||||
{0.0f, 1.0f},
|
||||
{1.0f, 0.0f},
|
||||
{1.0f, 1.0f}
|
||||
};
|
||||
|
||||
/*
|
||||
* Represents texcoords for the above. We can use the position values directly.
|
||||
* TODO: Duplicate these in the shader, no need to create a buffer.
|
||||
*/
|
||||
static const struct vlVertex2f *surface_texcoords = surface_verts;
|
||||
|
||||
/*
|
||||
* Identity color conversion constants, for debugging
|
||||
*/
|
||||
static const struct vlFragmentShaderConsts identity =
|
||||
{
|
||||
{
|
||||
0.0f, 0.0f, 0.0f, 0.0f
|
||||
},
|
||||
{
|
||||
1.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 1.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 1.0f
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Converts ITU-R BT.601 YCbCr pixels to RGB pixels where:
|
||||
* Y is in [16,235], Cb and Cr are in [16,240]
|
||||
* R, G, and B are in [16,235]
|
||||
*/
|
||||
static const struct vlFragmentShaderConsts bt_601 =
|
||||
{
|
||||
{
|
||||
0.0f, 0.501960784f, 0.501960784f, 0.0f
|
||||
},
|
||||
{
|
||||
1.0f, 0.0f, 1.371f, 0.0f,
|
||||
1.0f, -0.336f, -0.698f, 0.0f,
|
||||
1.0f, 1.732f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 1.0f
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Converts ITU-R BT.601 YCbCr pixels to RGB pixels where:
|
||||
* Y is in [16,235], Cb and Cr are in [16,240]
|
||||
* R, G, and B are in [0,255]
|
||||
*/
|
||||
static const struct vlFragmentShaderConsts bt_601_full =
|
||||
{
|
||||
{
|
||||
0.062745098f, 0.501960784f, 0.501960784f, 0.0f
|
||||
},
|
||||
{
|
||||
1.164f, 0.0f, 1.596f, 0.0f,
|
||||
1.164f, -0.391f, -0.813f, 0.0f,
|
||||
1.164f, 2.018f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 1.0f
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Converts ITU-R BT.709 YCbCr pixels to RGB pixels where:
|
||||
* Y is in [16,235], Cb and Cr are in [16,240]
|
||||
* R, G, and B are in [16,235]
|
||||
*/
|
||||
static const struct vlFragmentShaderConsts bt_709 =
|
||||
{
|
||||
{
|
||||
0.0f, 0.501960784f, 0.501960784f, 0.0f
|
||||
},
|
||||
{
|
||||
1.0f, 0.0f, 1.540f, 0.0f,
|
||||
1.0f, -0.183f, -0.459f, 0.0f,
|
||||
1.0f, 1.816f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 1.0f
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Converts ITU-R BT.709 YCbCr pixels to RGB pixels where:
|
||||
* Y is in [16,235], Cb and Cr are in [16,240]
|
||||
* R, G, and B are in [0,255]
|
||||
*/
|
||||
const struct vlFragmentShaderConsts bt_709_full =
|
||||
{
|
||||
{
|
||||
0.062745098f, 0.501960784f, 0.501960784f, 0.0f
|
||||
},
|
||||
{
|
||||
1.164f, 0.0f, 1.793f, 0.0f,
|
||||
1.164f, -0.213f, -0.534f, 0.0f,
|
||||
1.164f, 2.115f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 1.0f
|
||||
}
|
||||
};
|
||||
|
||||
static int vlCreateVertexShader
|
||||
(
|
||||
struct vlBasicCSC *csc
|
||||
)
|
||||
{
|
||||
const unsigned int max_tokens = 50;
|
||||
|
||||
struct pipe_context *pipe;
|
||||
struct pipe_shader_state vs;
|
||||
struct tgsi_token *tokens;
|
||||
struct tgsi_header *header;
|
||||
|
||||
struct tgsi_full_declaration decl;
|
||||
struct tgsi_full_instruction inst;
|
||||
|
||||
unsigned int ti;
|
||||
unsigned int i;
|
||||
|
||||
assert(csc);
|
||||
|
||||
pipe = csc->pipe;
|
||||
tokens = (struct tgsi_token*)MALLOC(max_tokens * sizeof(struct tgsi_token));
|
||||
|
||||
/* Version */
|
||||
*(struct tgsi_version*)&tokens[0] = tgsi_build_version();
|
||||
/* Header */
|
||||
header = (struct tgsi_header*)&tokens[1];
|
||||
*header = tgsi_build_header();
|
||||
/* Processor */
|
||||
*(struct tgsi_processor*)&tokens[2] = tgsi_build_processor(TGSI_PROCESSOR_VERTEX, header);
|
||||
|
||||
ti = 3;
|
||||
|
||||
/*
|
||||
* decl i0 ; Vertex pos
|
||||
* decl i1 ; Vertex texcoords
|
||||
*/
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
decl = vl_decl_input(i == 0 ? TGSI_SEMANTIC_POSITION : TGSI_SEMANTIC_GENERIC, i, i, i);
|
||||
ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
|
||||
}
|
||||
|
||||
/*
|
||||
* decl c0 ; Scaling vector to scale vertex pos rect to destination size
|
||||
* decl c1 ; Translation vector to move vertex pos rect into position
|
||||
* decl c2 ; Scaling vector to scale texcoord rect to source size
|
||||
* decl c3 ; Translation vector to move texcoord rect into position
|
||||
*/
|
||||
decl = vl_decl_constants(TGSI_SEMANTIC_GENERIC, 0, 0, 3);
|
||||
ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
|
||||
|
||||
/*
|
||||
* decl o0 ; Vertex pos
|
||||
* decl o1 ; Vertex texcoords
|
||||
*/
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
decl = vl_decl_output(i == 0 ? TGSI_SEMANTIC_POSITION : TGSI_SEMANTIC_GENERIC, i, i, i);
|
||||
ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
|
||||
}
|
||||
|
||||
/* decl t0, t1 */
|
||||
decl = vl_decl_temps(0, 1);
|
||||
ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
|
||||
|
||||
/*
|
||||
* madd o0, i0, c0, c1 ; Scale and translate unit output rect to destination size and pos
|
||||
* madd o1, i1, c2, c3 ; Scale and translate unit texcoord rect to source size and pos
|
||||
*/
|
||||
for (i = 0; i < 2; ++i)
|
||||
{
|
||||
inst = vl_inst4(TGSI_OPCODE_MAD, TGSI_FILE_OUTPUT, i, TGSI_FILE_INPUT, i, TGSI_FILE_CONSTANT, i * 2, TGSI_FILE_CONSTANT, i * 2 + 1);
|
||||
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
|
||||
}
|
||||
|
||||
/* end */
|
||||
inst = vl_end();
|
||||
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
|
||||
|
||||
vs.tokens = tokens;
|
||||
csc->vertex_shader = pipe->create_vs_state(pipe, &vs);
|
||||
FREE(tokens);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vlCreateFragmentShader
|
||||
(
|
||||
struct vlBasicCSC *csc
|
||||
)
|
||||
{
|
||||
const unsigned int max_tokens = 50;
|
||||
|
||||
struct pipe_context *pipe;
|
||||
struct pipe_shader_state fs;
|
||||
struct tgsi_token *tokens;
|
||||
struct tgsi_header *header;
|
||||
|
||||
struct tgsi_full_declaration decl;
|
||||
struct tgsi_full_instruction inst;
|
||||
|
||||
unsigned int ti;
|
||||
unsigned int i;
|
||||
|
||||
assert(csc);
|
||||
|
||||
pipe = csc->pipe;
|
||||
tokens = (struct tgsi_token*)MALLOC(max_tokens * sizeof(struct tgsi_token));
|
||||
|
||||
/* Version */
|
||||
*(struct tgsi_version*)&tokens[0] = tgsi_build_version();
|
||||
/* Header */
|
||||
header = (struct tgsi_header*)&tokens[1];
|
||||
*header = tgsi_build_header();
|
||||
/* Processor */
|
||||
*(struct tgsi_processor*)&tokens[2] = tgsi_build_processor(TGSI_PROCESSOR_FRAGMENT, header);
|
||||
|
||||
ti = 3;
|
||||
|
||||
/* decl i0 ; Texcoords for s0 */
|
||||
decl = vl_decl_interpolated_input(TGSI_SEMANTIC_GENERIC, 1, 0, 0, TGSI_INTERPOLATE_LINEAR);
|
||||
ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
|
||||
|
||||
/*
|
||||
* decl c0 ; Bias vector for CSC
|
||||
* decl c1-c4 ; CSC matrix c1-c4
|
||||
*/
|
||||
decl = vl_decl_constants(TGSI_SEMANTIC_GENERIC, 0, 0, 4);
|
||||
ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
|
||||
|
||||
/* decl o0 ; Fragment color */
|
||||
decl = vl_decl_output(TGSI_SEMANTIC_COLOR, 0, 0, 0);
|
||||
ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
|
||||
|
||||
/* decl t0 */
|
||||
decl = vl_decl_temps(0, 0);
|
||||
ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
|
||||
|
||||
/* decl s0 ; Sampler for tex containing picture to display */
|
||||
decl = vl_decl_samplers(0, 0);
|
||||
ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
|
||||
|
||||
/* tex2d t0, i0, s0 ; Read src pixel */
|
||||
inst = vl_tex(TGSI_TEXTURE_2D, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_INPUT, 0, TGSI_FILE_SAMPLER, 0);
|
||||
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
|
||||
|
||||
/* sub t0, t0, c0 ; Subtract bias vector from pixel */
|
||||
inst = vl_inst3(TGSI_OPCODE_SUB, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_CONSTANT, 0);
|
||||
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
|
||||
|
||||
/*
|
||||
* dp4 o0.x, t0, c1 ; Multiply pixel by the color conversion matrix
|
||||
* dp4 o0.y, t0, c2
|
||||
* dp4 o0.z, t0, c3
|
||||
*/
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
inst = vl_inst3(TGSI_OPCODE_DP4, TGSI_FILE_OUTPUT, 0, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_CONSTANT, i + 1);
|
||||
inst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_X << i;
|
||||
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
|
||||
}
|
||||
|
||||
/* end */
|
||||
inst = vl_end();
|
||||
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
|
||||
|
||||
fs.tokens = tokens;
|
||||
csc->fragment_shader = pipe->create_fs_state(pipe, &fs);
|
||||
FREE(tokens);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vlCreateDataBufs
|
||||
(
|
||||
struct vlBasicCSC *csc
|
||||
)
|
||||
{
|
||||
struct pipe_context *pipe;
|
||||
|
||||
assert(csc);
|
||||
|
||||
pipe = csc->pipe;
|
||||
|
||||
/*
|
||||
* Create our vertex buffer and vertex buffer element
|
||||
* VB contains 4 vertices that render a quad covering the entire window
|
||||
* to display a rendered surface
|
||||
* Quad is rendered as a tri strip
|
||||
*/
|
||||
csc->vertex_bufs[0].stride = sizeof(struct vlVertex2f);
|
||||
csc->vertex_bufs[0].max_index = 3;
|
||||
csc->vertex_bufs[0].buffer_offset = 0;
|
||||
csc->vertex_bufs[0].buffer = pipe_buffer_create
|
||||
(
|
||||
pipe->screen,
|
||||
1,
|
||||
PIPE_BUFFER_USAGE_VERTEX,
|
||||
sizeof(struct vlVertex2f) * 4
|
||||
);
|
||||
|
||||
memcpy
|
||||
(
|
||||
pipe_buffer_map(pipe->screen, csc->vertex_bufs[0].buffer, PIPE_BUFFER_USAGE_CPU_WRITE),
|
||||
surface_verts,
|
||||
sizeof(struct vlVertex2f) * 4
|
||||
);
|
||||
|
||||
pipe_buffer_unmap(pipe->screen, csc->vertex_bufs[0].buffer);
|
||||
|
||||
csc->vertex_elems[0].src_offset = 0;
|
||||
csc->vertex_elems[0].vertex_buffer_index = 0;
|
||||
csc->vertex_elems[0].nr_components = 2;
|
||||
csc->vertex_elems[0].src_format = PIPE_FORMAT_R32G32_FLOAT;
|
||||
|
||||
/*
|
||||
* Create our texcoord buffer and texcoord buffer element
|
||||
* Texcoord buffer contains the TCs for mapping the rendered surface to the 4 vertices
|
||||
*/
|
||||
csc->vertex_bufs[1].stride = sizeof(struct vlVertex2f);
|
||||
csc->vertex_bufs[1].max_index = 3;
|
||||
csc->vertex_bufs[1].buffer_offset = 0;
|
||||
csc->vertex_bufs[1].buffer = pipe_buffer_create
|
||||
(
|
||||
pipe->screen,
|
||||
1,
|
||||
PIPE_BUFFER_USAGE_VERTEX,
|
||||
sizeof(struct vlVertex2f) * 4
|
||||
);
|
||||
|
||||
memcpy
|
||||
(
|
||||
pipe_buffer_map(pipe->screen, csc->vertex_bufs[1].buffer, PIPE_BUFFER_USAGE_CPU_WRITE),
|
||||
surface_texcoords,
|
||||
sizeof(struct vlVertex2f) * 4
|
||||
);
|
||||
|
||||
pipe_buffer_unmap(pipe->screen, csc->vertex_bufs[1].buffer);
|
||||
|
||||
csc->vertex_elems[1].src_offset = 0;
|
||||
csc->vertex_elems[1].vertex_buffer_index = 1;
|
||||
csc->vertex_elems[1].nr_components = 2;
|
||||
csc->vertex_elems[1].src_format = PIPE_FORMAT_R32G32_FLOAT;
|
||||
|
||||
/*
|
||||
* Create our vertex shader's constant buffer
|
||||
* Const buffer contains scaling and translation vectors
|
||||
*/
|
||||
csc->vs_const_buf.buffer = pipe_buffer_create
|
||||
(
|
||||
pipe->screen,
|
||||
1,
|
||||
PIPE_BUFFER_USAGE_CONSTANT | PIPE_BUFFER_USAGE_DISCARD,
|
||||
sizeof(struct vlVertexShaderConsts)
|
||||
);
|
||||
|
||||
/*
|
||||
* Create our fragment shader's constant buffer
|
||||
* Const buffer contains the color conversion matrix and bias vectors
|
||||
*/
|
||||
csc->fs_const_buf.buffer = pipe_buffer_create
|
||||
(
|
||||
pipe->screen,
|
||||
1,
|
||||
PIPE_BUFFER_USAGE_CONSTANT,
|
||||
sizeof(struct vlFragmentShaderConsts)
|
||||
);
|
||||
|
||||
/*
|
||||
* TODO: Refactor this into a seperate function,
|
||||
* allow changing the CSC matrix at runtime to switch between regular & full versions
|
||||
*/
|
||||
memcpy
|
||||
(
|
||||
pipe_buffer_map(pipe->screen, csc->fs_const_buf.buffer, PIPE_BUFFER_USAGE_CPU_WRITE),
|
||||
&bt_601_full,
|
||||
sizeof(struct vlFragmentShaderConsts)
|
||||
);
|
||||
|
||||
pipe_buffer_unmap(pipe->screen, csc->fs_const_buf.buffer);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vlInit
|
||||
(
|
||||
struct vlBasicCSC *csc
|
||||
)
|
||||
{
|
||||
struct pipe_context *pipe;
|
||||
struct pipe_sampler_state sampler;
|
||||
|
||||
assert(csc);
|
||||
|
||||
pipe = csc->pipe;
|
||||
|
||||
/* Delay creating the FB until vlPutPictureCSC() so we know window size */
|
||||
csc->framebuffer_tex = NULL;
|
||||
csc->framebuffer.width = 0;
|
||||
csc->framebuffer.height = 0;
|
||||
csc->framebuffer.nr_cbufs = 1;
|
||||
csc->framebuffer.cbufs[0] = NULL;
|
||||
csc->framebuffer.zsbuf = NULL;
|
||||
|
||||
sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
|
||||
sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
|
||||
sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
|
||||
sampler.min_img_filter = PIPE_TEX_FILTER_LINEAR;
|
||||
sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
|
||||
sampler.mag_img_filter = PIPE_TEX_FILTER_LINEAR;
|
||||
sampler.compare_mode = PIPE_TEX_COMPARE_NONE;
|
||||
sampler.compare_func = PIPE_FUNC_ALWAYS;
|
||||
sampler.normalized_coords = 1;
|
||||
/*sampler.prefilter = ;*/
|
||||
/*sampler.lod_bias = ;*/
|
||||
/*sampler.min_lod = ;*/
|
||||
/*sampler.max_lod = ;*/
|
||||
/*sampler.border_color[i] = ;*/
|
||||
/*sampler.max_anisotropy = ;*/
|
||||
csc->sampler = pipe->create_sampler_state(pipe, &sampler);
|
||||
|
||||
vlCreateVertexShader(csc);
|
||||
vlCreateFragmentShader(csc);
|
||||
vlCreateDataBufs(csc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vlCreateBasicCSC
|
||||
(
|
||||
struct pipe_context *pipe,
|
||||
struct vlCSC **csc
|
||||
)
|
||||
{
|
||||
struct vlBasicCSC *basic_csc;
|
||||
|
||||
assert(pipe);
|
||||
assert(csc);
|
||||
|
||||
basic_csc = CALLOC_STRUCT(vlBasicCSC);
|
||||
|
||||
if (!basic_csc)
|
||||
return 1;
|
||||
|
||||
basic_csc->base.vlResizeFrameBuffer = &vlResizeFrameBuffer;
|
||||
basic_csc->base.vlBegin = &vlBegin;
|
||||
basic_csc->base.vlPutPicture = &vlPutPictureCSC;
|
||||
basic_csc->base.vlEnd = &vlEnd;
|
||||
basic_csc->base.vlGetFrameBuffer = &vlGetFrameBuffer;
|
||||
basic_csc->base.vlDestroy = &vlDestroy;
|
||||
basic_csc->pipe = pipe;
|
||||
|
||||
vlInit(basic_csc);
|
||||
|
||||
*csc = &basic_csc->base;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
#ifndef vl_basic_csc_h
|
||||
#define vl_basic_csc_h
|
||||
|
||||
struct pipe_context;
|
||||
struct vlCSC;
|
||||
|
||||
int vlCreateBasicCSC
|
||||
(
|
||||
struct pipe_context *pipe,
|
||||
struct vlCSC **csc
|
||||
);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,204 +0,0 @@
|
|||
#define VL_INTERNAL
|
||||
#include "vl_context.h"
|
||||
#include <assert.h>
|
||||
#include <pipe/p_context.h>
|
||||
#include <pipe/p_state.h>
|
||||
#include <util/u_memory.h>
|
||||
#include "vl_render.h"
|
||||
#include "vl_r16snorm_mc_buf.h"
|
||||
#include "vl_csc.h"
|
||||
#include "vl_basic_csc.h"
|
||||
|
||||
static int vlInitCommon(struct vlContext *context)
|
||||
{
|
||||
struct pipe_context *pipe;
|
||||
struct pipe_rasterizer_state rast;
|
||||
struct pipe_blend_state blend;
|
||||
struct pipe_depth_stencil_alpha_state dsa;
|
||||
unsigned int i;
|
||||
|
||||
assert(context);
|
||||
|
||||
pipe = context->pipe;
|
||||
|
||||
rast.flatshade = 1;
|
||||
rast.flatshade_first = 0;
|
||||
rast.light_twoside = 0;
|
||||
rast.front_winding = PIPE_WINDING_CCW;
|
||||
rast.cull_mode = PIPE_WINDING_CW;
|
||||
rast.fill_cw = PIPE_POLYGON_MODE_FILL;
|
||||
rast.fill_ccw = PIPE_POLYGON_MODE_FILL;
|
||||
rast.offset_cw = 0;
|
||||
rast.offset_ccw = 0;
|
||||
rast.scissor = 0;
|
||||
rast.poly_smooth = 0;
|
||||
rast.poly_stipple_enable = 0;
|
||||
rast.point_sprite = 0;
|
||||
rast.point_size_per_vertex = 0;
|
||||
rast.multisample = 0;
|
||||
rast.line_smooth = 0;
|
||||
rast.line_stipple_enable = 0;
|
||||
rast.line_stipple_factor = 0;
|
||||
rast.line_stipple_pattern = 0;
|
||||
rast.line_last_pixel = 0;
|
||||
rast.bypass_vs_clip_and_viewport = 0;
|
||||
rast.line_width = 1;
|
||||
rast.point_smooth = 0;
|
||||
rast.point_size = 1;
|
||||
rast.offset_units = 1;
|
||||
rast.offset_scale = 1;
|
||||
/*rast.sprite_coord_mode[i] = ;*/
|
||||
context->raster = pipe->create_rasterizer_state(pipe, &rast);
|
||||
pipe->bind_rasterizer_state(pipe, context->raster);
|
||||
|
||||
blend.blend_enable = 0;
|
||||
blend.rgb_func = PIPE_BLEND_ADD;
|
||||
blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE;
|
||||
blend.rgb_dst_factor = PIPE_BLENDFACTOR_ONE;
|
||||
blend.alpha_func = PIPE_BLEND_ADD;
|
||||
blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE;
|
||||
blend.alpha_dst_factor = PIPE_BLENDFACTOR_ONE;
|
||||
blend.logicop_enable = 0;
|
||||
blend.logicop_func = PIPE_LOGICOP_CLEAR;
|
||||
/* Needed to allow color writes to FB, even if blending disabled */
|
||||
blend.colormask = PIPE_MASK_RGBA;
|
||||
blend.dither = 0;
|
||||
context->blend = pipe->create_blend_state(pipe, &blend);
|
||||
pipe->bind_blend_state(pipe, context->blend);
|
||||
|
||||
dsa.depth.enabled = 0;
|
||||
dsa.depth.writemask = 0;
|
||||
dsa.depth.func = PIPE_FUNC_ALWAYS;
|
||||
for (i = 0; i < 2; ++i)
|
||||
{
|
||||
dsa.stencil[i].enabled = 0;
|
||||
dsa.stencil[i].func = PIPE_FUNC_ALWAYS;
|
||||
dsa.stencil[i].fail_op = PIPE_STENCIL_OP_KEEP;
|
||||
dsa.stencil[i].zpass_op = PIPE_STENCIL_OP_KEEP;
|
||||
dsa.stencil[i].zfail_op = PIPE_STENCIL_OP_KEEP;
|
||||
dsa.stencil[i].ref_value = 0;
|
||||
dsa.stencil[i].valuemask = 0;
|
||||
dsa.stencil[i].writemask = 0;
|
||||
}
|
||||
dsa.alpha.enabled = 0;
|
||||
dsa.alpha.func = PIPE_FUNC_ALWAYS;
|
||||
dsa.alpha.ref_value = 0;
|
||||
context->dsa = pipe->create_depth_stencil_alpha_state(pipe, &dsa);
|
||||
pipe->bind_depth_stencil_alpha_state(pipe, context->dsa);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vlCreateContext
|
||||
(
|
||||
struct vlScreen *screen,
|
||||
struct pipe_context *pipe,
|
||||
unsigned int picture_width,
|
||||
unsigned int picture_height,
|
||||
enum vlFormat picture_format,
|
||||
enum vlProfile profile,
|
||||
enum vlEntryPoint entry_point,
|
||||
struct vlContext **context
|
||||
)
|
||||
{
|
||||
struct vlContext *ctx;
|
||||
|
||||
assert(screen);
|
||||
assert(context);
|
||||
assert(pipe);
|
||||
|
||||
ctx = CALLOC_STRUCT(vlContext);
|
||||
|
||||
if (!ctx)
|
||||
return 1;
|
||||
|
||||
ctx->screen = screen;
|
||||
ctx->pipe = pipe;
|
||||
ctx->picture_width = picture_width;
|
||||
ctx->picture_height = picture_height;
|
||||
ctx->picture_format = picture_format;
|
||||
ctx->profile = profile;
|
||||
ctx->entry_point = entry_point;
|
||||
|
||||
vlInitCommon(ctx);
|
||||
|
||||
vlCreateR16SNormBufferedMC(pipe, picture_width, picture_height, picture_format, &ctx->render);
|
||||
vlCreateBasicCSC(pipe, &ctx->csc);
|
||||
|
||||
*context = ctx;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vlDestroyContext
|
||||
(
|
||||
struct vlContext *context
|
||||
)
|
||||
{
|
||||
assert(context);
|
||||
|
||||
/* XXX: Must unbind shaders before we can delete them for some reason */
|
||||
context->pipe->bind_vs_state(context->pipe, NULL);
|
||||
context->pipe->bind_fs_state(context->pipe, NULL);
|
||||
|
||||
context->render->vlDestroy(context->render);
|
||||
context->csc->vlDestroy(context->csc);
|
||||
|
||||
context->pipe->delete_blend_state(context->pipe, context->blend);
|
||||
context->pipe->delete_rasterizer_state(context->pipe, context->raster);
|
||||
context->pipe->delete_depth_stencil_alpha_state(context->pipe, context->dsa);
|
||||
|
||||
FREE(context);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct vlScreen* vlContextGetScreen
|
||||
(
|
||||
struct vlContext *context
|
||||
)
|
||||
{
|
||||
assert(context);
|
||||
|
||||
return context->screen;
|
||||
}
|
||||
|
||||
struct pipe_context* vlGetPipeContext
|
||||
(
|
||||
struct vlContext *context
|
||||
)
|
||||
{
|
||||
assert(context);
|
||||
|
||||
return context->pipe;
|
||||
}
|
||||
|
||||
unsigned int vlGetPictureWidth
|
||||
(
|
||||
struct vlContext *context
|
||||
)
|
||||
{
|
||||
assert(context);
|
||||
|
||||
return context->picture_width;
|
||||
}
|
||||
|
||||
unsigned int vlGetPictureHeight
|
||||
(
|
||||
struct vlContext *context
|
||||
)
|
||||
{
|
||||
assert(context);
|
||||
|
||||
return context->picture_height;
|
||||
}
|
||||
|
||||
enum vlFormat vlGetPictureFormat
|
||||
(
|
||||
struct vlContext *context
|
||||
)
|
||||
{
|
||||
assert(context);
|
||||
|
||||
return context->picture_format;
|
||||
}
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
#ifndef vl_context_h
|
||||
#define vl_context_h
|
||||
|
||||
#include "vl_types.h"
|
||||
|
||||
struct pipe_context;
|
||||
|
||||
#ifdef VL_INTERNAL
|
||||
struct vlRender;
|
||||
struct vlCSC;
|
||||
|
||||
struct vlContext
|
||||
{
|
||||
struct vlScreen *screen;
|
||||
struct pipe_context *pipe;
|
||||
unsigned int picture_width;
|
||||
unsigned int picture_height;
|
||||
enum vlFormat picture_format;
|
||||
enum vlProfile profile;
|
||||
enum vlEntryPoint entry_point;
|
||||
|
||||
void *raster;
|
||||
void *dsa;
|
||||
void *blend;
|
||||
|
||||
struct vlRender *render;
|
||||
struct vlCSC *csc;
|
||||
};
|
||||
#endif
|
||||
|
||||
int vlCreateContext
|
||||
(
|
||||
struct vlScreen *screen,
|
||||
struct pipe_context *pipe,
|
||||
unsigned int picture_width,
|
||||
unsigned int picture_height,
|
||||
enum vlFormat picture_format,
|
||||
enum vlProfile profile,
|
||||
enum vlEntryPoint entry_point,
|
||||
struct vlContext **context
|
||||
);
|
||||
|
||||
int vlDestroyContext
|
||||
(
|
||||
struct vlContext *context
|
||||
);
|
||||
|
||||
struct vlScreen* vlContextGetScreen
|
||||
(
|
||||
struct vlContext *context
|
||||
);
|
||||
|
||||
struct pipe_context* vlGetPipeContext
|
||||
(
|
||||
struct vlContext *context
|
||||
);
|
||||
|
||||
unsigned int vlGetPictureWidth
|
||||
(
|
||||
struct vlContext *context
|
||||
);
|
||||
|
||||
unsigned int vlGetPictureHeight
|
||||
(
|
||||
struct vlContext *context
|
||||
);
|
||||
|
||||
enum vlFormat vlGetPictureFormat
|
||||
(
|
||||
struct vlContext *context
|
||||
);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
#ifndef vl_csc_h
|
||||
#define vl_csc_h
|
||||
|
||||
#include "vl_types.h"
|
||||
|
||||
struct pipe_surface;
|
||||
|
||||
struct vlCSC
|
||||
{
|
||||
int (*vlResizeFrameBuffer)
|
||||
(
|
||||
struct vlCSC *csc,
|
||||
unsigned int width,
|
||||
unsigned int height
|
||||
);
|
||||
|
||||
int (*vlBegin)
|
||||
(
|
||||
struct vlCSC *csc
|
||||
);
|
||||
|
||||
int (*vlPutPicture)
|
||||
(
|
||||
struct vlCSC *csc,
|
||||
struct vlSurface *surface,
|
||||
int srcx,
|
||||
int srcy,
|
||||
int srcw,
|
||||
int srch,
|
||||
int destx,
|
||||
int desty,
|
||||
int destw,
|
||||
int desth,
|
||||
enum vlPictureType picture_type
|
||||
);
|
||||
|
||||
int (*vlEnd)
|
||||
(
|
||||
struct vlCSC *csc
|
||||
);
|
||||
|
||||
struct pipe_surface* (*vlGetFrameBuffer)
|
||||
(
|
||||
struct vlCSC *csc
|
||||
);
|
||||
|
||||
int (*vlDestroy)
|
||||
(
|
||||
struct vlCSC *csc
|
||||
);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
#ifndef vl_defs_h
|
||||
#define vl_defs_h
|
||||
|
||||
#define VL_BLOCK_WIDTH 8
|
||||
#define VL_BLOCK_HEIGHT 8
|
||||
#define VL_BLOCK_SIZE (VL_BLOCK_WIDTH * VL_BLOCK_HEIGHT)
|
||||
#define VL_MACROBLOCK_WIDTH 16
|
||||
#define VL_MACROBLOCK_HEIGHT 16
|
||||
#define VL_MACROBLOCK_SIZE (VL_MACROBLOCK_WIDTH * VL_MACROBLOCK_HEIGHT)
|
||||
|
||||
#endif
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
#define VL_INTERNAL
|
||||
#include "vl_display.h"
|
||||
#include <assert.h>
|
||||
#include <util/u_memory.h>
|
||||
|
||||
int vlCreateDisplay
|
||||
(
|
||||
vlNativeDisplay native_display,
|
||||
struct vlDisplay **display
|
||||
)
|
||||
{
|
||||
struct vlDisplay *dpy;
|
||||
|
||||
assert(native_display);
|
||||
assert(display);
|
||||
|
||||
dpy = CALLOC_STRUCT(vlDisplay);
|
||||
|
||||
if (!dpy)
|
||||
return 1;
|
||||
|
||||
dpy->native = native_display;
|
||||
*display = dpy;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vlDestroyDisplay
|
||||
(
|
||||
struct vlDisplay *display
|
||||
)
|
||||
{
|
||||
assert(display);
|
||||
|
||||
FREE(display);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
vlNativeDisplay vlGetNativeDisplay
|
||||
(
|
||||
struct vlDisplay *display
|
||||
)
|
||||
{
|
||||
assert(display);
|
||||
|
||||
return display->native;
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
#ifndef vl_display_h
|
||||
#define vl_display_h
|
||||
|
||||
#include "vl_types.h"
|
||||
|
||||
#ifdef VL_INTERNAL
|
||||
struct vlDisplay
|
||||
{
|
||||
vlNativeDisplay native;
|
||||
};
|
||||
#endif
|
||||
|
||||
int vlCreateDisplay
|
||||
(
|
||||
vlNativeDisplay native_display,
|
||||
struct vlDisplay **display
|
||||
);
|
||||
|
||||
int vlDestroyDisplay
|
||||
(
|
||||
struct vlDisplay *display
|
||||
);
|
||||
|
||||
vlNativeDisplay vlGetNativeDisplay
|
||||
(
|
||||
struct vlDisplay *display
|
||||
);
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,18 +0,0 @@
|
|||
#ifndef vl_r16snorm_mc_buf_h
|
||||
#define vl_r16snorm_mc_buf_h
|
||||
|
||||
#include "vl_types.h"
|
||||
|
||||
struct pipe_context;
|
||||
struct vlRender;
|
||||
|
||||
int vlCreateR16SNormBufferedMC
|
||||
(
|
||||
struct pipe_context *pipe,
|
||||
unsigned int picture_width,
|
||||
unsigned int picture_height,
|
||||
enum vlFormat picture_format,
|
||||
struct vlRender **render
|
||||
);
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,38 +0,0 @@
|
|||
#ifndef vl_render_h
|
||||
#define vl_render_h
|
||||
|
||||
#include "vl_types.h"
|
||||
|
||||
struct pipe_surface;
|
||||
|
||||
struct vlRender
|
||||
{
|
||||
int (*vlBegin)
|
||||
(
|
||||
struct vlRender *render
|
||||
);
|
||||
|
||||
int (*vlRenderMacroBlocksMpeg2)
|
||||
(
|
||||
struct vlRender *render,
|
||||
struct vlMpeg2MacroBlockBatch *batch,
|
||||
struct vlSurface *surface
|
||||
);
|
||||
|
||||
int (*vlEnd)
|
||||
(
|
||||
struct vlRender *render
|
||||
);
|
||||
|
||||
int (*vlFlush)
|
||||
(
|
||||
struct vlRender *render
|
||||
);
|
||||
|
||||
int (*vlDestroy)
|
||||
(
|
||||
struct vlRender *render
|
||||
);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
#define VL_INTERNAL
|
||||
#include "vl_screen.h"
|
||||
#include <assert.h>
|
||||
#include <util/u_memory.h>
|
||||
|
||||
int vlCreateScreen
|
||||
(
|
||||
struct vlDisplay *display,
|
||||
int screen,
|
||||
struct pipe_screen *pscreen,
|
||||
struct vlScreen **vl_screen
|
||||
)
|
||||
{
|
||||
struct vlScreen *scrn;
|
||||
|
||||
assert(display);
|
||||
assert(pscreen);
|
||||
assert(vl_screen);
|
||||
|
||||
scrn = CALLOC_STRUCT(vlScreen);
|
||||
|
||||
if (!scrn)
|
||||
return 1;
|
||||
|
||||
scrn->display = display;
|
||||
scrn->ordinal = screen;
|
||||
scrn->pscreen = pscreen;
|
||||
*vl_screen = scrn;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vlDestroyScreen
|
||||
(
|
||||
struct vlScreen *screen
|
||||
)
|
||||
{
|
||||
assert(screen);
|
||||
|
||||
FREE(screen);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct vlDisplay* vlGetDisplay
|
||||
(
|
||||
struct vlScreen *screen
|
||||
)
|
||||
{
|
||||
assert(screen);
|
||||
|
||||
return screen->display;
|
||||
}
|
||||
|
||||
struct pipe_screen* vlGetPipeScreen
|
||||
(
|
||||
struct vlScreen *screen
|
||||
)
|
||||
{
|
||||
assert(screen);
|
||||
|
||||
return screen->pscreen;
|
||||
}
|
||||
|
||||
unsigned int vlGetMaxProfiles
|
||||
(
|
||||
struct vlScreen *screen
|
||||
)
|
||||
{
|
||||
assert(screen);
|
||||
|
||||
return vlProfileCount;
|
||||
}
|
||||
|
||||
int vlQueryProfiles
|
||||
(
|
||||
struct vlScreen *screen,
|
||||
enum vlProfile *profiles
|
||||
)
|
||||
{
|
||||
assert(screen);
|
||||
assert(profiles);
|
||||
|
||||
profiles[0] = vlProfileMpeg2Simple;
|
||||
profiles[1] = vlProfileMpeg2Main;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int vlGetMaxEntryPoints
|
||||
(
|
||||
struct vlScreen *screen
|
||||
)
|
||||
{
|
||||
assert(screen);
|
||||
|
||||
return vlEntryPointCount;
|
||||
}
|
||||
|
||||
int vlQueryEntryPoints
|
||||
(
|
||||
struct vlScreen *screen,
|
||||
enum vlProfile profile,
|
||||
enum vlEntryPoint *entry_points
|
||||
)
|
||||
{
|
||||
assert(screen);
|
||||
assert(entry_points);
|
||||
|
||||
entry_points[0] = vlEntryPointIDCT;
|
||||
entry_points[1] = vlEntryPointMC;
|
||||
entry_points[2] = vlEntryPointCSC;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
#ifndef vl_screen_h
|
||||
#define vl_screen_h
|
||||
|
||||
#include "vl_types.h"
|
||||
|
||||
struct pipe_screen;
|
||||
|
||||
#ifdef VL_INTERNAL
|
||||
struct vlScreen
|
||||
{
|
||||
struct vlDisplay *display;
|
||||
unsigned int ordinal;
|
||||
struct pipe_screen *pscreen;
|
||||
};
|
||||
#endif
|
||||
|
||||
int vlCreateScreen
|
||||
(
|
||||
struct vlDisplay *display,
|
||||
int screen,
|
||||
struct pipe_screen *pscreen,
|
||||
struct vlScreen **vl_screen
|
||||
);
|
||||
|
||||
int vlDestroyScreen
|
||||
(
|
||||
struct vlScreen *screen
|
||||
);
|
||||
|
||||
struct vlDisplay* vlGetDisplay
|
||||
(
|
||||
struct vlScreen *screen
|
||||
);
|
||||
|
||||
struct pipe_screen* vlGetPipeScreen
|
||||
(
|
||||
struct vlScreen *screen
|
||||
);
|
||||
|
||||
unsigned int vlGetMaxProfiles
|
||||
(
|
||||
struct vlScreen *screen
|
||||
);
|
||||
|
||||
int vlQueryProfiles
|
||||
(
|
||||
struct vlScreen *screen,
|
||||
enum vlProfile *profiles
|
||||
);
|
||||
|
||||
unsigned int vlGetMaxEntryPoints
|
||||
(
|
||||
struct vlScreen *screen
|
||||
);
|
||||
|
||||
int vlQueryEntryPoints
|
||||
(
|
||||
struct vlScreen *screen,
|
||||
enum vlProfile profile,
|
||||
enum vlEntryPoint *entry_points
|
||||
);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,215 +0,0 @@
|
|||
#include "vl_shader_build.h"
|
||||
#include <assert.h>
|
||||
#include <tgsi/tgsi_parse.h>
|
||||
#include <tgsi/tgsi_build.h>
|
||||
|
||||
struct tgsi_full_declaration vl_decl_input(unsigned int name, unsigned int index, unsigned int first, unsigned int last)
|
||||
{
|
||||
struct tgsi_full_declaration decl = tgsi_default_full_declaration();
|
||||
|
||||
decl.Declaration.File = TGSI_FILE_INPUT;
|
||||
decl.Declaration.Semantic = 1;
|
||||
decl.Semantic.SemanticName = name;
|
||||
decl.Semantic.SemanticIndex = index;
|
||||
decl.DeclarationRange.First = first;
|
||||
decl.DeclarationRange.Last = last;
|
||||
|
||||
return decl;
|
||||
}
|
||||
|
||||
struct tgsi_full_declaration vl_decl_interpolated_input
|
||||
(
|
||||
unsigned int name,
|
||||
unsigned int index,
|
||||
unsigned int first,
|
||||
unsigned int last,
|
||||
int interpolation
|
||||
)
|
||||
{
|
||||
struct tgsi_full_declaration decl = tgsi_default_full_declaration();
|
||||
|
||||
assert
|
||||
(
|
||||
interpolation == TGSI_INTERPOLATE_CONSTANT ||
|
||||
interpolation == TGSI_INTERPOLATE_LINEAR ||
|
||||
interpolation == TGSI_INTERPOLATE_PERSPECTIVE
|
||||
);
|
||||
|
||||
decl.Declaration.File = TGSI_FILE_INPUT;
|
||||
decl.Declaration.Semantic = 1;
|
||||
decl.Semantic.SemanticName = name;
|
||||
decl.Semantic.SemanticIndex = index;
|
||||
decl.Declaration.Interpolate = interpolation;;
|
||||
decl.DeclarationRange.First = first;
|
||||
decl.DeclarationRange.Last = last;
|
||||
|
||||
return decl;
|
||||
}
|
||||
|
||||
struct tgsi_full_declaration vl_decl_constants(unsigned int name, unsigned int index, unsigned int first, unsigned int last)
|
||||
{
|
||||
struct tgsi_full_declaration decl = tgsi_default_full_declaration();
|
||||
|
||||
decl.Declaration.File = TGSI_FILE_CONSTANT;
|
||||
decl.Declaration.Semantic = 1;
|
||||
decl.Semantic.SemanticName = name;
|
||||
decl.Semantic.SemanticIndex = index;
|
||||
decl.DeclarationRange.First = first;
|
||||
decl.DeclarationRange.Last = last;
|
||||
|
||||
return decl;
|
||||
}
|
||||
|
||||
struct tgsi_full_declaration vl_decl_output(unsigned int name, unsigned int index, unsigned int first, unsigned int last)
|
||||
{
|
||||
struct tgsi_full_declaration decl = tgsi_default_full_declaration();
|
||||
|
||||
decl.Declaration.File = TGSI_FILE_OUTPUT;
|
||||
decl.Declaration.Semantic = 1;
|
||||
decl.Semantic.SemanticName = name;
|
||||
decl.Semantic.SemanticIndex = index;
|
||||
decl.DeclarationRange.First = first;
|
||||
decl.DeclarationRange.Last = last;
|
||||
|
||||
return decl;
|
||||
}
|
||||
|
||||
struct tgsi_full_declaration vl_decl_temps(unsigned int first, unsigned int last)
|
||||
{
|
||||
struct tgsi_full_declaration decl = tgsi_default_full_declaration();
|
||||
|
||||
decl = tgsi_default_full_declaration();
|
||||
decl.Declaration.File = TGSI_FILE_TEMPORARY;
|
||||
decl.DeclarationRange.First = first;
|
||||
decl.DeclarationRange.Last = last;
|
||||
|
||||
return decl;
|
||||
}
|
||||
|
||||
struct tgsi_full_declaration vl_decl_samplers(unsigned int first, unsigned int last)
|
||||
{
|
||||
struct tgsi_full_declaration decl = tgsi_default_full_declaration();
|
||||
|
||||
decl = tgsi_default_full_declaration();
|
||||
decl.Declaration.File = TGSI_FILE_SAMPLER;
|
||||
decl.DeclarationRange.First = first;
|
||||
decl.DeclarationRange.Last = last;
|
||||
|
||||
return decl;
|
||||
}
|
||||
|
||||
struct tgsi_full_instruction vl_inst2
|
||||
(
|
||||
int opcode,
|
||||
enum tgsi_file_type dst_file,
|
||||
unsigned int dst_index,
|
||||
enum tgsi_file_type src_file,
|
||||
unsigned int src_index
|
||||
)
|
||||
{
|
||||
struct tgsi_full_instruction inst = tgsi_default_full_instruction();
|
||||
|
||||
inst.Instruction.Opcode = opcode;
|
||||
inst.Instruction.NumDstRegs = 1;
|
||||
inst.FullDstRegisters[0].DstRegister.File = dst_file;
|
||||
inst.FullDstRegisters[0].DstRegister.Index = dst_index;
|
||||
inst.Instruction.NumSrcRegs = 1;
|
||||
inst.FullSrcRegisters[0].SrcRegister.File = src_file;
|
||||
inst.FullSrcRegisters[0].SrcRegister.Index = src_index;
|
||||
|
||||
return inst;
|
||||
}
|
||||
|
||||
struct tgsi_full_instruction vl_inst3
|
||||
(
|
||||
int opcode,
|
||||
enum tgsi_file_type dst_file,
|
||||
unsigned int dst_index,
|
||||
enum tgsi_file_type src1_file,
|
||||
unsigned int src1_index,
|
||||
enum tgsi_file_type src2_file,
|
||||
unsigned int src2_index
|
||||
)
|
||||
{
|
||||
struct tgsi_full_instruction inst = tgsi_default_full_instruction();
|
||||
|
||||
inst.Instruction.Opcode = opcode;
|
||||
inst.Instruction.NumDstRegs = 1;
|
||||
inst.FullDstRegisters[0].DstRegister.File = dst_file;
|
||||
inst.FullDstRegisters[0].DstRegister.Index = dst_index;
|
||||
inst.Instruction.NumSrcRegs = 2;
|
||||
inst.FullSrcRegisters[0].SrcRegister.File = src1_file;
|
||||
inst.FullSrcRegisters[0].SrcRegister.Index = src1_index;
|
||||
inst.FullSrcRegisters[1].SrcRegister.File = src2_file;
|
||||
inst.FullSrcRegisters[1].SrcRegister.Index = src2_index;
|
||||
|
||||
return inst;
|
||||
}
|
||||
|
||||
struct tgsi_full_instruction vl_tex
|
||||
(
|
||||
int tex,
|
||||
enum tgsi_file_type dst_file,
|
||||
unsigned int dst_index,
|
||||
enum tgsi_file_type src1_file,
|
||||
unsigned int src1_index,
|
||||
enum tgsi_file_type src2_file,
|
||||
unsigned int src2_index
|
||||
)
|
||||
{
|
||||
struct tgsi_full_instruction inst = tgsi_default_full_instruction();
|
||||
|
||||
inst.Instruction.Opcode = TGSI_OPCODE_TEX;
|
||||
inst.Instruction.NumDstRegs = 1;
|
||||
inst.FullDstRegisters[0].DstRegister.File = dst_file;
|
||||
inst.FullDstRegisters[0].DstRegister.Index = dst_index;
|
||||
inst.Instruction.NumSrcRegs = 2;
|
||||
inst.InstructionExtTexture.Texture = tex;
|
||||
inst.FullSrcRegisters[0].SrcRegister.File = src1_file;
|
||||
inst.FullSrcRegisters[0].SrcRegister.Index = src1_index;
|
||||
inst.FullSrcRegisters[1].SrcRegister.File = src2_file;
|
||||
inst.FullSrcRegisters[1].SrcRegister.Index = src2_index;
|
||||
|
||||
return inst;
|
||||
}
|
||||
|
||||
struct tgsi_full_instruction vl_inst4
|
||||
(
|
||||
int opcode,
|
||||
enum tgsi_file_type dst_file,
|
||||
unsigned int dst_index,
|
||||
enum tgsi_file_type src1_file,
|
||||
unsigned int src1_index,
|
||||
enum tgsi_file_type src2_file,
|
||||
unsigned int src2_index,
|
||||
enum tgsi_file_type src3_file,
|
||||
unsigned int src3_index
|
||||
)
|
||||
{
|
||||
struct tgsi_full_instruction inst = tgsi_default_full_instruction();
|
||||
|
||||
inst.Instruction.Opcode = opcode;
|
||||
inst.Instruction.NumDstRegs = 1;
|
||||
inst.FullDstRegisters[0].DstRegister.File = dst_file;
|
||||
inst.FullDstRegisters[0].DstRegister.Index = dst_index;
|
||||
inst.Instruction.NumSrcRegs = 3;
|
||||
inst.FullSrcRegisters[0].SrcRegister.File = src1_file;
|
||||
inst.FullSrcRegisters[0].SrcRegister.Index = src1_index;
|
||||
inst.FullSrcRegisters[1].SrcRegister.File = src2_file;
|
||||
inst.FullSrcRegisters[1].SrcRegister.Index = src2_index;
|
||||
inst.FullSrcRegisters[2].SrcRegister.File = src3_file;
|
||||
inst.FullSrcRegisters[2].SrcRegister.Index = src3_index;
|
||||
|
||||
return inst;
|
||||
}
|
||||
|
||||
struct tgsi_full_instruction vl_end(void)
|
||||
{
|
||||
struct tgsi_full_instruction inst = tgsi_default_full_instruction();
|
||||
|
||||
inst.Instruction.Opcode = TGSI_OPCODE_END;
|
||||
inst.Instruction.NumDstRegs = 0;
|
||||
inst.Instruction.NumSrcRegs = 0;
|
||||
|
||||
return inst;
|
||||
}
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
#ifndef vl_shader_build_h
|
||||
#define vl_shader_build_h
|
||||
|
||||
#include <pipe/p_shader_tokens.h>
|
||||
|
||||
struct tgsi_full_declaration vl_decl_input(unsigned int name, unsigned int index, unsigned int first, unsigned int last);
|
||||
struct tgsi_full_declaration vl_decl_interpolated_input
|
||||
(
|
||||
unsigned int name,
|
||||
unsigned int index,
|
||||
unsigned int first,
|
||||
unsigned int last,
|
||||
int interpolation
|
||||
);
|
||||
struct tgsi_full_declaration vl_decl_constants(unsigned int name, unsigned int index, unsigned int first, unsigned int last);
|
||||
struct tgsi_full_declaration vl_decl_output(unsigned int name, unsigned int index, unsigned int first, unsigned int last);
|
||||
struct tgsi_full_declaration vl_decl_temps(unsigned int first, unsigned int last);
|
||||
struct tgsi_full_declaration vl_decl_samplers(unsigned int first, unsigned int last);
|
||||
struct tgsi_full_instruction vl_inst2
|
||||
(
|
||||
int opcode,
|
||||
enum tgsi_file_type dst_file,
|
||||
unsigned int dst_index,
|
||||
enum tgsi_file_type src_file,
|
||||
unsigned int src_index
|
||||
);
|
||||
struct tgsi_full_instruction vl_inst3
|
||||
(
|
||||
int opcode,
|
||||
enum tgsi_file_type dst_file,
|
||||
unsigned int dst_index,
|
||||
enum tgsi_file_type src1_file,
|
||||
unsigned int src1_index,
|
||||
enum tgsi_file_type src2_file,
|
||||
unsigned int src2_index
|
||||
);
|
||||
struct tgsi_full_instruction vl_tex
|
||||
(
|
||||
int tex,
|
||||
enum tgsi_file_type dst_file,
|
||||
unsigned int dst_index,
|
||||
enum tgsi_file_type src1_file,
|
||||
unsigned int src1_index,
|
||||
enum tgsi_file_type src2_file,
|
||||
unsigned int src2_index
|
||||
);
|
||||
struct tgsi_full_instruction vl_inst4
|
||||
(
|
||||
int opcode,
|
||||
enum tgsi_file_type dst_file,
|
||||
unsigned int dst_index,
|
||||
enum tgsi_file_type src1_file,
|
||||
unsigned int src1_index,
|
||||
enum tgsi_file_type src2_file,
|
||||
unsigned int src2_index,
|
||||
enum tgsi_file_type src3_file,
|
||||
unsigned int src3_index
|
||||
);
|
||||
struct tgsi_full_instruction vl_end(void);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,242 +0,0 @@
|
|||
#define VL_INTERNAL
|
||||
#include "vl_surface.h"
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <pipe/p_screen.h>
|
||||
#include <pipe/p_state.h>
|
||||
#include <pipe/p_inlines.h>
|
||||
#include <util/u_memory.h>
|
||||
#include <vl_winsys.h>
|
||||
#include "vl_screen.h"
|
||||
#include "vl_context.h"
|
||||
#include "vl_render.h"
|
||||
#include "vl_csc.h"
|
||||
#include "vl_util.h"
|
||||
|
||||
int vlCreateSurface
|
||||
(
|
||||
struct vlScreen *screen,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
enum vlFormat format,
|
||||
struct vlSurface **surface
|
||||
)
|
||||
{
|
||||
struct vlSurface *sfc;
|
||||
struct pipe_texture template;
|
||||
|
||||
assert(screen);
|
||||
assert(surface);
|
||||
|
||||
sfc = CALLOC_STRUCT(vlSurface);
|
||||
|
||||
if (!sfc)
|
||||
return 1;
|
||||
|
||||
sfc->screen = screen;
|
||||
sfc->width = width;
|
||||
sfc->height = height;
|
||||
sfc->format = format;
|
||||
|
||||
memset(&template, 0, sizeof(struct pipe_texture));
|
||||
template.target = PIPE_TEXTURE_2D;
|
||||
template.format = PIPE_FORMAT_A8R8G8B8_UNORM;
|
||||
template.last_level = 0;
|
||||
template.width[0] = vlRoundUpPOT(sfc->width);
|
||||
template.height[0] = vlRoundUpPOT(sfc->height);
|
||||
template.depth[0] = 1;
|
||||
pf_get_block(template.format, &template.block);
|
||||
template.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER | PIPE_TEXTURE_USAGE_RENDER_TARGET;
|
||||
|
||||
sfc->texture = vlGetPipeScreen(screen)->texture_create(vlGetPipeScreen(screen), &template);
|
||||
|
||||
if (!sfc->texture)
|
||||
{
|
||||
FREE(sfc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
*surface = sfc;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vlDestroySurface
|
||||
(
|
||||
struct vlSurface *surface
|
||||
)
|
||||
{
|
||||
assert(surface);
|
||||
|
||||
pipe_texture_reference(&surface->texture, NULL);
|
||||
FREE(surface);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vlRenderMacroBlocksMpeg2
|
||||
(
|
||||
struct vlMpeg2MacroBlockBatch *batch,
|
||||
struct vlSurface *surface
|
||||
)
|
||||
{
|
||||
assert(batch);
|
||||
assert(surface);
|
||||
assert(surface->context);
|
||||
|
||||
surface->context->render->vlBegin(surface->context->render);
|
||||
|
||||
surface->context->render->vlRenderMacroBlocksMpeg2
|
||||
(
|
||||
surface->context->render,
|
||||
batch,
|
||||
surface
|
||||
);
|
||||
|
||||
surface->context->render->vlEnd(surface->context->render);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vlPutPicture
|
||||
(
|
||||
struct vlSurface *surface,
|
||||
vlNativeDrawable drawable,
|
||||
int srcx,
|
||||
int srcy,
|
||||
int srcw,
|
||||
int srch,
|
||||
int destx,
|
||||
int desty,
|
||||
int destw,
|
||||
int desth,
|
||||
int drawable_w,
|
||||
int drawable_h,
|
||||
enum vlPictureType picture_type
|
||||
)
|
||||
{
|
||||
struct vlCSC *csc;
|
||||
struct pipe_context *pipe;
|
||||
|
||||
assert(surface);
|
||||
assert(surface->context);
|
||||
|
||||
surface->context->render->vlFlush(surface->context->render);
|
||||
|
||||
csc = surface->context->csc;
|
||||
pipe = surface->context->pipe;
|
||||
|
||||
csc->vlResizeFrameBuffer(csc, drawable_w, drawable_h);
|
||||
|
||||
csc->vlBegin(csc);
|
||||
|
||||
csc->vlPutPicture
|
||||
(
|
||||
csc,
|
||||
surface,
|
||||
srcx,
|
||||
srcy,
|
||||
srcw,
|
||||
srch,
|
||||
destx,
|
||||
desty,
|
||||
destw,
|
||||
desth,
|
||||
picture_type
|
||||
);
|
||||
|
||||
csc->vlEnd(csc);
|
||||
|
||||
pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, &surface->disp_fence);
|
||||
|
||||
bind_pipe_drawable(pipe, drawable);
|
||||
|
||||
pipe->screen->flush_frontbuffer
|
||||
(
|
||||
pipe->screen,
|
||||
csc->vlGetFrameBuffer(csc),
|
||||
pipe->priv
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vlSurfaceGetStatus
|
||||
(
|
||||
struct vlSurface *surface,
|
||||
enum vlResourceStatus *status
|
||||
)
|
||||
{
|
||||
assert(surface);
|
||||
assert(surface->context);
|
||||
assert(status);
|
||||
|
||||
if (surface->render_fence && !surface->context->pipe->screen->fence_signalled(surface->context->pipe->screen, surface->render_fence, 0))
|
||||
{
|
||||
*status = vlResourceStatusRendering;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (surface->disp_fence && !surface->context->pipe->screen->fence_signalled(surface->context->pipe->screen, surface->disp_fence, 0))
|
||||
{
|
||||
*status = vlResourceStatusDisplaying;
|
||||
return 0;
|
||||
}
|
||||
|
||||
*status = vlResourceStatusFree;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vlSurfaceFlush
|
||||
(
|
||||
struct vlSurface *surface
|
||||
)
|
||||
{
|
||||
assert(surface);
|
||||
assert(surface->context);
|
||||
|
||||
surface->context->render->vlFlush(surface->context->render);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vlSurfaceSync
|
||||
(
|
||||
struct vlSurface *surface
|
||||
)
|
||||
{
|
||||
assert(surface);
|
||||
assert(surface->context);
|
||||
assert(surface->render_fence);
|
||||
|
||||
surface->context->pipe->screen->fence_finish(surface->context->pipe->screen, surface->render_fence, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct vlScreen* vlSurfaceGetScreen
|
||||
(
|
||||
struct vlSurface *surface
|
||||
)
|
||||
{
|
||||
assert(surface);
|
||||
|
||||
return surface->screen;
|
||||
}
|
||||
|
||||
struct vlContext* vlBindToContext
|
||||
(
|
||||
struct vlSurface *surface,
|
||||
struct vlContext *context
|
||||
)
|
||||
{
|
||||
struct vlContext *old;
|
||||
|
||||
assert(surface);
|
||||
|
||||
old = surface->context;
|
||||
surface->context = context;
|
||||
|
||||
return old;
|
||||
}
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
#ifndef vl_surface_h
|
||||
#define vl_surface_h
|
||||
|
||||
#include "vl_types.h"
|
||||
|
||||
#ifdef VL_INTERNAL
|
||||
struct pipe_texture;
|
||||
|
||||
struct vlSurface
|
||||
{
|
||||
struct vlScreen *screen;
|
||||
struct vlContext *context;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
enum vlFormat format;
|
||||
struct pipe_texture *texture;
|
||||
struct pipe_fence_handle *render_fence;
|
||||
struct pipe_fence_handle *disp_fence;
|
||||
};
|
||||
#endif
|
||||
|
||||
int vlCreateSurface
|
||||
(
|
||||
struct vlScreen *screen,
|
||||
unsigned int width,
|
||||
unsigned int height,
|
||||
enum vlFormat format,
|
||||
struct vlSurface **surface
|
||||
);
|
||||
|
||||
int vlDestroySurface
|
||||
(
|
||||
struct vlSurface *surface
|
||||
);
|
||||
|
||||
int vlRenderMacroBlocksMpeg2
|
||||
(
|
||||
struct vlMpeg2MacroBlockBatch *batch,
|
||||
struct vlSurface *surface
|
||||
);
|
||||
|
||||
int vlPutPicture
|
||||
(
|
||||
struct vlSurface *surface,
|
||||
vlNativeDrawable drawable,
|
||||
int srcx,
|
||||
int srcy,
|
||||
int srcw,
|
||||
int srch,
|
||||
int destx,
|
||||
int desty,
|
||||
int destw,
|
||||
int desth,
|
||||
int drawable_w,
|
||||
int drawable_h,
|
||||
enum vlPictureType picture_type
|
||||
);
|
||||
|
||||
int vlSurfaceGetStatus
|
||||
(
|
||||
struct vlSurface *surface,
|
||||
enum vlResourceStatus *status
|
||||
);
|
||||
|
||||
int vlSurfaceFlush
|
||||
(
|
||||
struct vlSurface *surface
|
||||
);
|
||||
|
||||
int vlSurfaceSync
|
||||
(
|
||||
struct vlSurface *surface
|
||||
);
|
||||
|
||||
struct vlScreen* vlSurfaceGetScreen
|
||||
(
|
||||
struct vlSurface *surface
|
||||
);
|
||||
|
||||
struct vlContext* vlBindToContext
|
||||
(
|
||||
struct vlSurface *surface,
|
||||
struct vlContext *context
|
||||
);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
#ifndef vl_types_h
|
||||
#define vl_types_h
|
||||
|
||||
#if 1 /*#ifdef X11*/
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
typedef Display* vlNativeDisplay;
|
||||
typedef Drawable vlNativeDrawable;
|
||||
#endif
|
||||
|
||||
struct vlDisplay;
|
||||
struct vlScreen;
|
||||
struct vlContext;
|
||||
struct vlSurface;
|
||||
|
||||
enum vlResourceStatus
|
||||
{
|
||||
vlResourceStatusFree,
|
||||
vlResourceStatusRendering,
|
||||
vlResourceStatusDisplaying
|
||||
};
|
||||
|
||||
enum vlProfile
|
||||
{
|
||||
vlProfileMpeg2Simple,
|
||||
vlProfileMpeg2Main,
|
||||
|
||||
vlProfileCount
|
||||
};
|
||||
|
||||
enum vlEntryPoint
|
||||
{
|
||||
vlEntryPointIDCT,
|
||||
vlEntryPointMC,
|
||||
vlEntryPointCSC,
|
||||
|
||||
vlEntryPointCount
|
||||
};
|
||||
|
||||
enum vlFormat
|
||||
{
|
||||
vlFormatYCbCr420,
|
||||
vlFormatYCbCr422,
|
||||
vlFormatYCbCr444
|
||||
};
|
||||
|
||||
enum vlPictureType
|
||||
{
|
||||
vlPictureTypeTopField,
|
||||
vlPictureTypeBottomField,
|
||||
vlPictureTypeFrame
|
||||
};
|
||||
|
||||
enum vlMotionType
|
||||
{
|
||||
vlMotionTypeField,
|
||||
vlMotionTypeFrame,
|
||||
vlMotionTypeDualPrime,
|
||||
vlMotionType16x8
|
||||
};
|
||||
|
||||
enum vlFieldOrder
|
||||
{
|
||||
vlFieldOrderFirst,
|
||||
vlFieldOrderSecond
|
||||
};
|
||||
|
||||
enum vlDCTType
|
||||
{
|
||||
vlDCTTypeFrameCoded,
|
||||
vlDCTTypeFieldCoded
|
||||
};
|
||||
|
||||
struct vlVertex2f
|
||||
{
|
||||
float x, y;
|
||||
};
|
||||
|
||||
struct vlVertex4f
|
||||
{
|
||||
float x, y, z, w;
|
||||
};
|
||||
|
||||
enum vlMacroBlockType
|
||||
{
|
||||
vlMacroBlockTypeIntra,
|
||||
vlMacroBlockTypeFwdPredicted,
|
||||
vlMacroBlockTypeBkwdPredicted,
|
||||
vlMacroBlockTypeBiPredicted,
|
||||
|
||||
vlNumMacroBlockTypes
|
||||
};
|
||||
|
||||
struct vlMpeg2MacroBlock
|
||||
{
|
||||
unsigned int mbx, mby;
|
||||
enum vlMacroBlockType mb_type;
|
||||
enum vlMotionType mo_type;
|
||||
enum vlDCTType dct_type;
|
||||
int PMV[2][2][2];
|
||||
unsigned int cbp;
|
||||
short *blocks;
|
||||
};
|
||||
|
||||
struct vlMpeg2MacroBlockBatch
|
||||
{
|
||||
struct vlSurface *past_surface;
|
||||
struct vlSurface *future_surface;
|
||||
enum vlPictureType picture_type;
|
||||
enum vlFieldOrder field_order;
|
||||
unsigned int num_macroblocks;
|
||||
struct vlMpeg2MacroBlock *macroblocks;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
#include "vl_util.h"
|
||||
#include <assert.h>
|
||||
|
||||
unsigned int vlRoundUpPOT(unsigned int x)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
assert(x > 0);
|
||||
|
||||
--x;
|
||||
|
||||
for (i = 1; i < sizeof(unsigned int) * 8; i <<= 1)
|
||||
x |= x >> i;
|
||||
|
||||
return x + 1;
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
#ifndef vl_util_h
|
||||
#define vl_util_h
|
||||
|
||||
unsigned int vlRoundUpPOT(unsigned int x);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,291 +0,0 @@
|
|||
#include "vl_winsys.h"
|
||||
#include <X11/Xutil.h>
|
||||
#include <pipe/internal/p_winsys_screen.h>
|
||||
#include <pipe/p_state.h>
|
||||
#include <pipe/p_inlines.h>
|
||||
#include <util/u_memory.h>
|
||||
#include <util/u_math.h>
|
||||
#include <softpipe/sp_winsys.h>
|
||||
#include <softpipe/sp_texture.h>
|
||||
|
||||
/* pipe_winsys implementation */
|
||||
|
||||
struct xsp_pipe_winsys
|
||||
{
|
||||
struct pipe_winsys base;
|
||||
XImage fbimage;
|
||||
};
|
||||
|
||||
struct xsp_context
|
||||
{
|
||||
Display *display;
|
||||
int screen;
|
||||
Drawable drawable;
|
||||
int drawable_bound;
|
||||
};
|
||||
|
||||
struct xsp_buffer
|
||||
{
|
||||
struct pipe_buffer base;
|
||||
boolean is_user_buffer;
|
||||
void *data;
|
||||
void *mapped_data;
|
||||
};
|
||||
|
||||
static struct pipe_buffer* xsp_buffer_create(struct pipe_winsys *pws, unsigned alignment, unsigned usage, unsigned size)
|
||||
{
|
||||
struct xsp_buffer *buffer;
|
||||
|
||||
assert(pws);
|
||||
|
||||
buffer = calloc(1, sizeof(struct xsp_buffer));
|
||||
pipe_reference_init(&buffer->base.reference, 1);
|
||||
buffer->base.alignment = alignment;
|
||||
buffer->base.usage = usage;
|
||||
buffer->base.size = size;
|
||||
buffer->data = align_malloc(size, alignment);
|
||||
|
||||
return (struct pipe_buffer*)buffer;
|
||||
}
|
||||
|
||||
static struct pipe_buffer* xsp_user_buffer_create(struct pipe_winsys *pws, void *data, unsigned size)
|
||||
{
|
||||
struct xsp_buffer *buffer;
|
||||
|
||||
assert(pws);
|
||||
|
||||
buffer = calloc(1, sizeof(struct xsp_buffer));
|
||||
pipe_reference_init(&buffer->base.reference, 1);
|
||||
buffer->base.size = size;
|
||||
buffer->is_user_buffer = TRUE;
|
||||
buffer->data = data;
|
||||
|
||||
return (struct pipe_buffer*)buffer;
|
||||
}
|
||||
|
||||
static void* xsp_buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buffer, unsigned flags)
|
||||
{
|
||||
struct xsp_buffer *xsp_buf = (struct xsp_buffer*)buffer;
|
||||
|
||||
assert(pws);
|
||||
assert(buffer);
|
||||
|
||||
xsp_buf->mapped_data = xsp_buf->data;
|
||||
|
||||
return xsp_buf->mapped_data;
|
||||
}
|
||||
|
||||
static void xsp_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buffer)
|
||||
{
|
||||
struct xsp_buffer *xsp_buf = (struct xsp_buffer*)buffer;
|
||||
|
||||
assert(pws);
|
||||
assert(buffer);
|
||||
|
||||
xsp_buf->mapped_data = NULL;
|
||||
}
|
||||
|
||||
static void xsp_buffer_destroy(struct pipe_winsys *pws, struct pipe_buffer *buffer)
|
||||
{
|
||||
struct xsp_buffer *xsp_buf = (struct xsp_buffer*)buffer;
|
||||
|
||||
assert(pws);
|
||||
assert(buffer);
|
||||
|
||||
if (!xsp_buf->is_user_buffer)
|
||||
align_free(xsp_buf->data);
|
||||
|
||||
free(xsp_buf);
|
||||
}
|
||||
|
||||
static struct pipe_buffer* xsp_surface_buffer_create
|
||||
(
|
||||
struct pipe_winsys *pws,
|
||||
unsigned width,
|
||||
unsigned height,
|
||||
enum pipe_format format,
|
||||
unsigned usage,
|
||||
unsigned tex_usage,
|
||||
unsigned *stride
|
||||
)
|
||||
{
|
||||
const unsigned int ALIGNMENT = 1;
|
||||
struct pipe_format_block block;
|
||||
unsigned nblocksx, nblocksy;
|
||||
|
||||
pf_get_block(format, &block);
|
||||
nblocksx = pf_get_nblocksx(&block, width);
|
||||
nblocksy = pf_get_nblocksy(&block, height);
|
||||
*stride = align(nblocksx * block.size, ALIGNMENT);
|
||||
|
||||
return pws->buffer_create(pws, ALIGNMENT,
|
||||
usage,
|
||||
*stride * nblocksy);
|
||||
}
|
||||
|
||||
static void xsp_fence_reference(struct pipe_winsys *pws, struct pipe_fence_handle **ptr, struct pipe_fence_handle *fence)
|
||||
{
|
||||
assert(pws);
|
||||
assert(ptr);
|
||||
assert(fence);
|
||||
}
|
||||
|
||||
static int xsp_fence_signalled(struct pipe_winsys *pws, struct pipe_fence_handle *fence, unsigned flag)
|
||||
{
|
||||
assert(pws);
|
||||
assert(fence);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xsp_fence_finish(struct pipe_winsys *pws, struct pipe_fence_handle *fence, unsigned flag)
|
||||
{
|
||||
assert(pws);
|
||||
assert(fence);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void xsp_flush_frontbuffer(struct pipe_winsys *pws, struct pipe_surface *surface, void *context_private)
|
||||
{
|
||||
struct xsp_pipe_winsys *xsp_winsys;
|
||||
struct xsp_context *xsp_context;
|
||||
|
||||
assert(pws);
|
||||
assert(surface);
|
||||
assert(context_private);
|
||||
|
||||
xsp_winsys = (struct xsp_pipe_winsys*)pws;
|
||||
xsp_context = (struct xsp_context*)context_private;
|
||||
|
||||
if (!xsp_context->drawable_bound)
|
||||
return;
|
||||
|
||||
xsp_winsys->fbimage.width = surface->width;
|
||||
xsp_winsys->fbimage.height = surface->height;
|
||||
xsp_winsys->fbimage.bytes_per_line = surface->width * (xsp_winsys->fbimage.bits_per_pixel >> 3);
|
||||
xsp_winsys->fbimage.data = ((struct xsp_buffer *)softpipe_texture(surface->texture)->buffer)->data + surface->offset;
|
||||
|
||||
XPutImage
|
||||
(
|
||||
xsp_context->display,
|
||||
xsp_context->drawable,
|
||||
XDefaultGC(xsp_context->display, xsp_context->screen),
|
||||
&xsp_winsys->fbimage,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
surface->width,
|
||||
surface->height
|
||||
);
|
||||
XFlush(xsp_context->display);
|
||||
}
|
||||
|
||||
static const char* xsp_get_name(struct pipe_winsys *pws)
|
||||
{
|
||||
assert(pws);
|
||||
return "X11 SoftPipe";
|
||||
}
|
||||
|
||||
/* Show starts here */
|
||||
|
||||
int bind_pipe_drawable(struct pipe_context *pipe, Drawable drawable)
|
||||
{
|
||||
struct xsp_context *xsp_context;
|
||||
|
||||
assert(pipe);
|
||||
|
||||
xsp_context = pipe->priv;
|
||||
xsp_context->drawable = drawable;
|
||||
xsp_context->drawable_bound = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int unbind_pipe_drawable(struct pipe_context *pipe)
|
||||
{
|
||||
struct xsp_context *xsp_context;
|
||||
|
||||
assert(pipe);
|
||||
|
||||
xsp_context = pipe->priv;
|
||||
xsp_context->drawable_bound = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct pipe_context* create_pipe_context(Display *display, int screen)
|
||||
{
|
||||
struct xsp_pipe_winsys *xsp_winsys;
|
||||
struct xsp_context *xsp_context;
|
||||
struct pipe_screen *sp_screen;
|
||||
struct pipe_context *sp_pipe;
|
||||
|
||||
assert(display);
|
||||
|
||||
xsp_winsys = calloc(1, sizeof(struct xsp_pipe_winsys));
|
||||
xsp_winsys->base.buffer_create = xsp_buffer_create;
|
||||
xsp_winsys->base.user_buffer_create = xsp_user_buffer_create;
|
||||
xsp_winsys->base.buffer_map = xsp_buffer_map;
|
||||
xsp_winsys->base.buffer_unmap = xsp_buffer_unmap;
|
||||
xsp_winsys->base.buffer_destroy = xsp_buffer_destroy;
|
||||
xsp_winsys->base.surface_buffer_create = xsp_surface_buffer_create;
|
||||
xsp_winsys->base.fence_reference = xsp_fence_reference;
|
||||
xsp_winsys->base.fence_signalled = xsp_fence_signalled;
|
||||
xsp_winsys->base.fence_finish = xsp_fence_finish;
|
||||
xsp_winsys->base.flush_frontbuffer = xsp_flush_frontbuffer;
|
||||
xsp_winsys->base.get_name = xsp_get_name;
|
||||
|
||||
{
|
||||
/* XXX: Can't use the returned XImage* directly,
|
||||
since we don't have control over winsys destruction
|
||||
and we wouldn't be able to free it */
|
||||
XImage *template = XCreateImage
|
||||
(
|
||||
display,
|
||||
XDefaultVisual(display, XDefaultScreen(display)),
|
||||
XDefaultDepth(display, XDefaultScreen(display)),
|
||||
ZPixmap,
|
||||
0,
|
||||
NULL,
|
||||
0, /* Don't know the width and height until flush_frontbuffer */
|
||||
0,
|
||||
32,
|
||||
0
|
||||
);
|
||||
|
||||
memcpy(&xsp_winsys->fbimage, template, sizeof(XImage));
|
||||
XInitImage(&xsp_winsys->fbimage);
|
||||
|
||||
XDestroyImage(template);
|
||||
}
|
||||
|
||||
sp_screen = softpipe_create_screen((struct pipe_winsys*)xsp_winsys);
|
||||
sp_pipe = softpipe_create(sp_screen);
|
||||
|
||||
xsp_context = calloc(1, sizeof(struct xsp_context));
|
||||
xsp_context->display = display;
|
||||
xsp_context->screen = screen;
|
||||
|
||||
sp_pipe->priv = xsp_context;
|
||||
|
||||
return sp_pipe;
|
||||
}
|
||||
|
||||
int destroy_pipe_context(struct pipe_context *pipe)
|
||||
{
|
||||
struct pipe_screen *screen;
|
||||
struct pipe_winsys *winsys;
|
||||
|
||||
assert(pipe);
|
||||
|
||||
screen = pipe->screen;
|
||||
winsys = pipe->winsys;
|
||||
free(pipe->priv);
|
||||
pipe->destroy(pipe);
|
||||
screen->destroy(screen);
|
||||
free(winsys);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue