g3dvl: Use rotating buffers to avoid waiting for map().

This commit is contained in:
Younes Manton 2008-08-18 00:04:29 -04:00
parent f90e50dff9
commit 7f100d04dd
7 changed files with 37 additions and 122 deletions

View file

@ -2,7 +2,7 @@ TARGET = libdriclient.a
OBJECTS = driclient.o XF86dri.o
DRMDIR ?= /usr
CFLAGS += -g -Wall -fPIC -Werror -I../include -I${DRMDIR}/include -I${DRMDIR}/include/drm
CFLAGS += -g -Wall -fPIC -I../include -I${DRMDIR}/include -I${DRMDIR}/include/drm
#############################################

View file

@ -1,9 +1,9 @@
TARGET = libg3dvl.a
OBJECTS = vl_display.o vl_screen.o vl_context.o vl_surface.o vl_data.o vl_shader_build.o vl_util.o vl_basic_csc.o \
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.o
GALLIUMDIR = ../..
CFLAGS += -g -Wall -fPIC -Werror -I${GALLIUMDIR}/include -I${GALLIUMDIR}/auxiliary -I${GALLIUMDIR}/winsys/g3dvl
CFLAGS += -g -Wall -fPIC -I${GALLIUMDIR}/include -I${GALLIUMDIR}/auxiliary -I${GALLIUMDIR}/winsys/g3dvl
#############################################

View file

@ -1,76 +0,0 @@
#include "vl_data.h"
/*
* Represents 8 triangles (4 quads, 1 per block) in noormalized coords
* that render a macroblock.
* Need to be scaled to cover mbW*mbH macroblock pixels and translated into
* position on target surface.
*/
const struct vlVertex2f macroblock_verts[24] =
{
{0.0f, 0.0f}, {0.0f, 0.5f}, {0.5f, 0.0f},
{0.5f, 0.0f}, {0.0f, 0.5f}, {0.5f, 0.5f},
{0.5f, 0.0f}, {0.5f, 0.5f}, {1.0f, 0.0f},
{1.0f, 0.0f}, {0.5f, 0.5f}, {1.0f, 0.5f},
{0.0f, 0.5f}, {0.0f, 1.0f}, {0.5f, 0.5f},
{0.5f, 0.5f}, {0.0f, 1.0f}, {0.5f, 1.0f},
{0.5f, 0.5f}, {0.5f, 1.0f}, {1.0f, 0.5f},
{1.0f, 0.5f}, {0.5f, 1.0f}, {1.0f, 1.0f}
};
/*
* Represents texcoords for the above for rendering 4 luma blocks arranged
* in a bW*(bH*4) texture. First luma block located at 0,0->bW,bH; second at
* 0,bH->bW,2bH; third at 0,2bH->bW,3bH; fourth at 0,3bH->bW,4bH.
*/
const struct vlVertex2f macroblock_luma_texcoords[24] =
{
{0.0f, 0.0f}, {0.0f, 0.25f}, {1.0f, 0.0f},
{1.0f, 0.0f}, {0.0f, 0.25f}, {1.0f, 0.25f},
{0.0f, 0.25f}, {0.0f, 0.5f}, {1.0f, 0.25f},
{1.0f, 0.25f}, {0.0f, 0.5f}, {1.0f, 0.5f},
{0.0f, 0.5f}, {0.0f, 0.75f}, {1.0f, 0.5f},
{1.0f, 0.5f}, {0.0f, 0.75f}, {1.0f, 0.75f},
{0.0f, 0.75f}, {0.0f, 1.0f}, {1.0f, 0.75f},
{1.0f, 0.75f}, {0.0f, 1.0f}, {1.0f, 1.0f}
};
/*
* Represents texcoords for the above for rendering 1 chroma block.
* Straight forward 0,0->1,1 mapping so we can reuse the MB pos vectors.
*/
const struct vlVertex2f *macroblock_chroma_420_texcoords = macroblock_verts;
/*
* Represents texcoords for the above for rendering 2 chroma blocks arranged
* in a bW*(bH*2) texture. First chroma block located at 0,0->bW,bH; second at
* 0,bH->bW,2bH. We can render this with 0,0->1,1 mapping.
* Straight forward 0,0->1,1 mapping so we can reuse MB pos vectors.
*/
const struct vlVertex2f *macroblock_chroma_422_texcoords = macroblock_verts;
/*
* Represents texcoords for the above for rendering 4 chroma blocks.
* Same case as 4 luma blocks.
*/
const struct vlVertex2f *macroblock_chroma_444_texcoords = macroblock_luma_texcoords;
/*
* Used when rendering P and B macroblocks, multiplier is applied to the A channel,
* which is then added to the L channel, then the bias is subtracted from that to
* get back the differential. The differential is then added to the samples from the
* reference surface(s).
*/
#if 0
const struct VL_MC_FS_CONSTS vl_mc_fs_consts =
{
{32767.0f / 255.0f, 32767.0f / 255.0f, 32767.0f / 255.0f, 0.0f},
{0.5f, 2.0f, 0.0f, 0.0f}
};
#endif

View file

@ -1,27 +0,0 @@
#ifndef vl_data_h
#define vl_data_h
#include "vl_types.h"
/* TODO: Needs to be rolled into the appropriate stage */
extern const struct vlVertex2f macroblock_verts[24];
extern const struct vlVertex2f macroblock_luma_texcoords[24];
extern const struct vlVertex2f *macroblock_chroma_420_texcoords;
extern const struct vlVertex2f *macroblock_chroma_422_texcoords;
extern const struct vlVertex2f *macroblock_chroma_444_texcoords;
extern const struct vlVertex2f surface_verts[4];
extern const struct vlVertex2f *surface_texcoords;
/*
extern const struct VL_MC_FS_CONSTS vl_mc_fs_consts;
extern const struct VL_CSC_FS_CONSTS vl_csc_fs_consts_identity;
extern const struct VL_CSC_FS_CONSTS vl_csc_fs_consts_601;
extern const struct VL_CSC_FS_CONSTS vl_csc_fs_consts_601_full;
extern const struct VL_CSC_FS_CONSTS vl_csc_fs_consts_709;
extern const struct VL_CSC_FS_CONSTS vl_csc_fs_consts_709_full;
*/
#endif

View file

@ -15,6 +15,8 @@
#include "vl_types.h"
#include "vl_defs.h"
#define NUM_BUFS 4 /* Number of rotating buffers to use */
struct vlVertexShaderConsts
{
/*struct vlVertex4f scale;
@ -41,12 +43,13 @@ struct vlR16SnormMC
unsigned int video_width, video_height;
enum vlFormat video_format;
unsigned int cur_buf;
struct pipe_context *pipe;
struct pipe_viewport_state viewport;
struct pipe_framebuffer_state render_target;
struct pipe_sampler_state *samplers[5];
struct pipe_texture *textures[5];
struct pipe_texture *textures[NUM_BUFS][5];
void *i_vs, *p_vs[2], *b_vs[2];
void *i_fs, *p_fs[2], *b_fs[2];
struct pipe_vertex_buffer vertex_bufs[3];
@ -230,7 +233,7 @@ static int vlGrabBlocks
tex_surface = mc->pipe->screen->get_tex_surface
(
mc->pipe->screen,
mc->textures[0],
mc->textures[mc->cur_buf % NUM_BUFS][0],
0, 0, 0, PIPE_BUFFER_USAGE_CPU_WRITE
);
@ -276,7 +279,7 @@ static int vlGrabBlocks
tex_surface = mc->pipe->screen->get_tex_surface
(
mc->pipe->screen,
mc->textures[tb + 1],
mc->textures[mc->cur_buf % NUM_BUFS][tb + 1],
0, 0, 0, PIPE_BUFFER_USAGE_CPU_WRITE
);
@ -361,12 +364,14 @@ int vlRenderIMacroBlock
0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE
);
pipe->set_framebuffer_state(pipe, &mc->render_target);
pipe->set_sampler_textures(pipe, 3, mc->textures);
pipe->set_sampler_textures(pipe, 3, mc->textures[mc->cur_buf % NUM_BUFS]);
pipe->bind_sampler_states(pipe, 3, (void**)mc->samplers);
pipe->bind_vs_state(pipe, mc->i_vs);
pipe->bind_fs_state(pipe, mc->i_fs);
pipe->draw_arrays(pipe, PIPE_PRIM_TRIANGLES, 0, 24);
mc->cur_buf++;
return 0;
}
@ -458,11 +463,13 @@ int vlRenderPMacroBlock
);
pipe->set_framebuffer_state(pipe, &mc->render_target);
mc->textures[3] = ref_surface->texture;
pipe->set_sampler_textures(pipe, 4, mc->textures);
mc->textures[mc->cur_buf % NUM_BUFS][3] = ref_surface->texture;
pipe->set_sampler_textures(pipe, 4, mc->textures[mc->cur_buf % NUM_BUFS]);
pipe->bind_sampler_states(pipe, 4, (void**)mc->samplers);
pipe->draw_arrays(pipe, PIPE_PRIM_TRIANGLES, 0, 24);
mc->cur_buf++;
return 0;
}
@ -567,12 +574,14 @@ int vlRenderBMacroBlock
);
pipe->set_framebuffer_state(pipe, &mc->render_target);
mc->textures[3] = past_surface->texture;
mc->textures[4] = future_surface->texture;
pipe->set_sampler_textures(pipe, 5, mc->textures);
mc->textures[mc->cur_buf % NUM_BUFS][3] = past_surface->texture;
mc->textures[mc->cur_buf % NUM_BUFS][4] = future_surface->texture;
pipe->set_sampler_textures(pipe, 5, mc->textures[mc->cur_buf % NUM_BUFS]);
pipe->bind_sampler_states(pipe, 5, (void**)mc->samplers);
pipe->draw_arrays(pipe, PIPE_PRIM_TRIANGLES, 0, 24);
mc->cur_buf++;
return 0;
}
@ -724,8 +733,12 @@ int vlDestroy
pipe->winsys->buffer_destroy(pipe->winsys, 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_texture_release(&mc->textures[i]);
for (i = 0; i < NUM_BUFS; ++i)
{
pipe_texture_release(&mc->textures[i][0]);
pipe_texture_release(&mc->textures[i][1]);
pipe_texture_release(&mc->textures[i][2]);
}
pipe->delete_vs_state(pipe, mc->i_vs);
pipe->delete_fs_state(pipe, mc->i_fs);
@ -2252,7 +2265,8 @@ static int vlInit
template.compressed = 0;
pf_get_block(template.format, &template.block);
mc->textures[0] = pipe->screen->texture_create(pipe->screen, &template);
for (i = 0; i < NUM_BUFS; ++i)
mc->textures[i][0] = pipe->screen->texture_create(pipe->screen, &template);
if (mc->video_format == vlFormatYCbCr420)
template.height[0] = 8;
@ -2263,8 +2277,11 @@ static int vlInit
else
assert(0);
mc->textures[1] = pipe->screen->texture_create(pipe->screen, &template);
mc->textures[2] = pipe->screen->texture_create(pipe->screen, &template);
for (i = 0; i < NUM_BUFS; ++i)
{
mc->textures[i][1] = pipe->screen->texture_create(pipe->screen, &template);
mc->textures[i][2] = pipe->screen->texture_create(pipe->screen, &template);
}
/* textures[3] & textures[4] are assigned from vlSurfaces for P and B macroblocks at render time */
@ -2306,6 +2323,7 @@ int vlCreateR16SNormMC
mc->pipe = pipe;
mc->video_width = video_width;
mc->video_height = video_height;
mc->cur_buf = 0;
vlInit(mc);

View file

@ -9,7 +9,7 @@ OBJECTS = nouveau_bo.o nouveau_fence.o nouveau_swapbuffers.o nouveau_channel.o
nouveau_pushbuf.o nouveau_resource.o nouveau_screen.o nv04_surface.o \
nv50_surface.o #nouveau_winsys_softpipe.o
CFLAGS += -g -Wall -Werror -fPIC \
CFLAGS += -g -Wall -fPIC \
-I${GALLIUMDIR}/include \
-I${GALLIUMDIR}/winsys/g3dvl \
-I${DRMDIR}/include \

View file

@ -8,7 +8,7 @@ ifeq (${DRIVER}, softpipe)
OBJECTS += ${GALLIUMDIR}/winsys/g3dvl/xsp_winsys.o
endif
CFLAGS += -g -fPIC -Wall -Werror \
CFLAGS += -g -fPIC -Wall \
-I${GALLIUMDIR}/state_trackers/g3dvl \
-I${GALLIUMDIR}/winsys/g3dvl \
-I${GALLIUMDIR}/include \