summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYounes Manton <younes.m@gmail.com>2008-09-10 19:37:56 -0400
committerYounes Manton <younes.m@gmail.com>2008-09-12 14:31:07 -0400
commitf3f449a49136ae2fd2dc3cf62d2c24dd42505e7d (patch)
tree7d135aea5fb122570bc397cfb75085559ade7400
parent42a42dec3dbb5e150584b3d0b2e14e9b555a4ac1 (diff)
g3dvl: Implement surface sync functions.
-rw-r--r--src/gallium/state_trackers/g3dvl/vl_r16snorm_mc_buf.c20
-rw-r--r--src/gallium/state_trackers/g3dvl/vl_surface.c59
-rw-r--r--src/gallium/state_trackers/g3dvl/vl_surface.h30
-rw-r--r--src/gallium/state_trackers/g3dvl/vl_types.h7
-rw-r--r--src/libXvMC/surface.c31
5 files changed, 123 insertions, 24 deletions
diff --git a/src/gallium/state_trackers/g3dvl/vl_r16snorm_mc_buf.c b/src/gallium/state_trackers/g3dvl/vl_r16snorm_mc_buf.c
index cfbad0803..75d326b36 100644
--- a/src/gallium/state_trackers/g3dvl/vl_r16snorm_mc_buf.c
+++ b/src/gallium/state_trackers/g3dvl/vl_r16snorm_mc_buf.c
@@ -591,6 +591,10 @@ static int vlFlush
assert(render);
mc = (struct vlR16SnormBufferedMC*)render;
+
+ if (!mc->buffered_surface)
+ return 0;
+
pipe = mc->pipe;
for (i = 0; i < mc->num_macroblocks; ++i)
@@ -736,8 +740,12 @@ static int vlFlush
vb_start += num_macroblocks[vlMacroBlockExTypeBiPredictedField] * 24;
}
+ pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, &mc->buffered_surface->render_fence);
+
for (i = 0; i < 3; ++i)
mc->zero_block[i].x = -1.0f;
+
+ mc->buffered_surface = NULL;
mc->num_macroblocks = 0;
mc->cur_buf++;
@@ -760,12 +768,7 @@ static int vlRenderMacroBlocksMpeg2R16SnormBuffered
if (mc->buffered_surface)
{
- if
- (
- mc->buffered_surface != surface /*||
- mc->past_surface != batch->past_surface ||
- mc->future_surface != batch->future_surface*/
- )
+ if (mc->buffered_surface != surface)
{
vlFlush(&mc->base);
mc->buffered_surface = surface;
@@ -1027,7 +1030,6 @@ static int vlCreateFragmentShaderIMB
inst.FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_X;
inst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_X << i;
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
}
/* mul o0, t0, c0 ; Rescale texel to correct range */
@@ -1323,7 +1325,6 @@ static int vlCreateFragmentShaderFramePMB
inst.FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_X;
inst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_X << i;
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
}
/* mul t0, t0, c0 ; Rescale texel to correct range */
@@ -1442,7 +1443,6 @@ static int vlCreateFragmentShaderFieldPMB
inst.FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_X;
inst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_X << i;
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
}
/* mul t0, t0, c0 ; Rescale texel to correct range */
@@ -1818,7 +1818,6 @@ static int vlCreateFragmentShaderFrameBMB
inst.FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_X;
inst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_X << i;
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
}
/* mul t0, t0, c0 ; Rescale texel to correct range */
@@ -1955,7 +1954,6 @@ static int vlCreateFragmentShaderFieldBMB
inst.FullSrcRegisters[0].SrcRegister.SwizzleZ = TGSI_SWIZZLE_X;
inst.FullDstRegisters[0].DstRegister.WriteMask = TGSI_WRITEMASK_X << i;
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
}
/* mul t0, t0, c0 ; Rescale texel to correct range */
diff --git a/src/gallium/state_trackers/g3dvl/vl_surface.c b/src/gallium/state_trackers/g3dvl/vl_surface.c
index 07a9be2a9..6648133ef 100644
--- a/src/gallium/state_trackers/g3dvl/vl_surface.c
+++ b/src/gallium/state_trackers/g3dvl/vl_surface.c
@@ -77,6 +77,7 @@ int vlRenderMacroBlocksMpeg2
{
assert(batch);
assert(surface);
+ assert(surface->context);
surface->context->render->vlBegin(surface->context->render);
@@ -141,9 +142,10 @@ int vlPutPicture
csc->vlEnd(csc);
- pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
+ pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, &surface->disp_fence);
+
bind_pipe_drawable(pipe, drawable);
- /* TODO: Need to take destx, desty into consideration */
+
pipe->winsys->flush_frontbuffer
(
pipe->winsys,
@@ -154,6 +156,59 @@ int vlPutPicture
return 0;
}
+int vlSurfaceGetStatus
+(
+ struct vlSurface *surface,
+ enum vlResourceStatus *status
+)
+{
+ assert(surface);
+ assert(surface->context);
+ assert(status);
+
+ if (surface->render_fence && !surface->context->pipe->winsys->fence_signalled(surface->context->pipe->winsys, surface->render_fence, 0))
+ {
+ *status = vlResourceStatusRendering;
+ return 0;
+ }
+
+ if (surface->disp_fence && !surface->context->pipe->winsys->fence_signalled(surface->context->pipe->winsys, 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->winsys->fence_finish(surface->context->pipe->winsys, surface->render_fence, 0);
+
+ return 0;
+}
+
struct vlScreen* vlSurfaceGetScreen
(
struct vlSurface *surface
diff --git a/src/gallium/state_trackers/g3dvl/vl_surface.h b/src/gallium/state_trackers/g3dvl/vl_surface.h
index 3e0505034..133e1515e 100644
--- a/src/gallium/state_trackers/g3dvl/vl_surface.h
+++ b/src/gallium/state_trackers/g3dvl/vl_surface.h
@@ -8,12 +8,14 @@ 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 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
@@ -54,6 +56,22 @@ int vlPutPicture
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
diff --git a/src/gallium/state_trackers/g3dvl/vl_types.h b/src/gallium/state_trackers/g3dvl/vl_types.h
index b432bfde9..274e1f743 100644
--- a/src/gallium/state_trackers/g3dvl/vl_types.h
+++ b/src/gallium/state_trackers/g3dvl/vl_types.h
@@ -13,6 +13,13 @@ struct vlScreen;
struct vlContext;
struct vlSurface;
+enum vlResourceStatus
+{
+ vlResourceStatusFree,
+ vlResourceStatusRendering,
+ vlResourceStatusDisplaying
+};
+
enum vlProfile
{
vlProfileMpeg2Simple,
diff --git a/src/libXvMC/surface.c b/src/libXvMC/surface.c
index b8459c03c..a920da52f 100644
--- a/src/libXvMC/surface.c
+++ b/src/libXvMC/surface.c
@@ -201,7 +201,7 @@ Status XvMCFlushSurface(Display *display, XvMCSurface *surface)
assert(display == vlGetNativeDisplay(vlGetDisplay(vlSurfaceGetScreen(vl_sfc))));
- /* TODO */
+ vlSurfaceFlush(vl_sfc);
return Success;
}
@@ -219,7 +219,7 @@ Status XvMCSyncSurface(Display *display, XvMCSurface *surface)
assert(display == vlGetNativeDisplay(vlGetDisplay(vlSurfaceGetScreen(vl_sfc))));
- /* TODO */
+ vlSurfaceSync(vl_sfc);
return Success;
}
@@ -273,7 +273,8 @@ Status XvMCPutSurface
Status XvMCGetSurfaceStatus(Display *display, XvMCSurface *surface, int *status)
{
- struct vlSurface *vl_sfc;
+ struct vlSurface *vl_sfc;
+ enum vlResourceStatus res_status;
assert(display);
@@ -286,8 +287,28 @@ Status XvMCGetSurfaceStatus(Display *display, XvMCSurface *surface, int *status)
assert(display == vlGetNativeDisplay(vlGetDisplay(vlSurfaceGetScreen(vl_sfc))));
- /* TODO */
- *status = 0;
+ vlSurfaceGetStatus(vl_sfc, &res_status);
+
+ switch (res_status)
+ {
+ case vlResourceStatusFree:
+ {
+ *status = 0;
+ break;
+ }
+ case vlResourceStatusRendering:
+ {
+ *status = XVMC_RENDERING;
+ break;
+ }
+ case vlResourceStatusDisplaying:
+ {
+ *status = XVMC_DISPLAYING;
+ break;
+ }
+ default:
+ assert(0);
+ }
return Success;
}