aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/g3dvl
diff options
context:
space:
mode:
authorYounes Manton <[email protected]>2008-08-18 00:04:29 -0400
committerYounes Manton <[email protected]>2008-08-18 00:04:29 -0400
commit7f100d04ddacf9f6517c9aff1e2de5257eb77fb0 (patch)
treefd7a6642bb2c1234b166365713d1653a1db998d0 /src/gallium/state_trackers/g3dvl
parentf90e50dff9e5cdbad6e9bb74c0aeaaaa82242b25 (diff)
g3dvl: Use rotating buffers to avoid waiting for map().
Diffstat (limited to 'src/gallium/state_trackers/g3dvl')
-rw-r--r--src/gallium/state_trackers/g3dvl/Makefile4
-rw-r--r--src/gallium/state_trackers/g3dvl/vl_data.c76
-rw-r--r--src/gallium/state_trackers/g3dvl/vl_data.h27
-rw-r--r--src/gallium/state_trackers/g3dvl/vl_r16snorm_mc.c46
4 files changed, 34 insertions, 119 deletions
diff --git a/src/gallium/state_trackers/g3dvl/Makefile b/src/gallium/state_trackers/g3dvl/Makefile
index 9995c554ab8..bd77c62bc58 100644
--- a/src/gallium/state_trackers/g3dvl/Makefile
+++ b/src/gallium/state_trackers/g3dvl/Makefile
@@ -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
#############################################
diff --git a/src/gallium/state_trackers/g3dvl/vl_data.c b/src/gallium/state_trackers/g3dvl/vl_data.c
deleted file mode 100644
index f2476dbf1ee..00000000000
--- a/src/gallium/state_trackers/g3dvl/vl_data.c
+++ /dev/null
@@ -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
diff --git a/src/gallium/state_trackers/g3dvl/vl_data.h b/src/gallium/state_trackers/g3dvl/vl_data.h
deleted file mode 100644
index f0de2e976ce..00000000000
--- a/src/gallium/state_trackers/g3dvl/vl_data.h
+++ /dev/null
@@ -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
diff --git a/src/gallium/state_trackers/g3dvl/vl_r16snorm_mc.c b/src/gallium/state_trackers/g3dvl/vl_r16snorm_mc.c
index 4fae2244310..80b09a6d1d0 100644
--- a/src/gallium/state_trackers/g3dvl/vl_r16snorm_mc.c
+++ b/src/gallium/state_trackers/g3dvl/vl_r16snorm_mc.c
@@ -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);