svga: Support accelerated conditional blitting
The blitter has functions to save and restore the conditional rendering state, but we currently don't save the needed info. Since also the copy_region_vgpu10 path supports conditional blitting, we instead use the same function as the clearing routines and move that function to svga_pipe_query.c Note that we still haven't implemented conditional blitting with the software fallbacks. Fixes piglit nv_conditional_render::copyteximage Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Charmaine Lee <charmainel@vmware.com>
This commit is contained in:
@@ -675,6 +675,9 @@ struct pipe_context *
|
||||
svga_context_create(struct pipe_screen *screen,
|
||||
void *priv, unsigned flags);
|
||||
|
||||
void svga_toggle_render_condition(struct svga_context *svga,
|
||||
boolean render_condition_enabled,
|
||||
boolean on);
|
||||
|
||||
/***********************************************************************
|
||||
* Inline conversion functions. These are better-typed than the
|
||||
|
||||
@@ -286,9 +286,6 @@ can_blit_via_svga_copy_region(struct svga_context *svga,
|
||||
blit_info->mask != (PIPE_MASK_ZS))
|
||||
return false;
|
||||
|
||||
if (svga->render_condition && blit_info->render_condition_enable)
|
||||
return false;
|
||||
|
||||
return check_blending_and_srgb_cond(svga, blit_info);
|
||||
}
|
||||
|
||||
@@ -334,6 +331,9 @@ can_blit_via_surface_copy(struct svga_context *svga,
|
||||
{
|
||||
struct svga_texture *dtex, *stex;
|
||||
|
||||
if (svga->render_condition && blit_info->render_condition_enable)
|
||||
return false;
|
||||
|
||||
/* can't copy between different resource types */
|
||||
if (svga_resource_type(blit_info->src.resource->target) !=
|
||||
svga_resource_type(blit_info->dst.resource->target))
|
||||
@@ -372,6 +372,8 @@ try_copy_region(struct svga_context *svga,
|
||||
&dst_face, &dst_z);
|
||||
|
||||
if (can_blit_via_copy_region_vgpu10(svga, blit)) {
|
||||
svga_toggle_render_condition(svga, blit->render_condition_enable, FALSE);
|
||||
|
||||
copy_region_vgpu10(svga,
|
||||
blit->src.resource,
|
||||
blit->src.box.x, blit->src.box.y, src_z,
|
||||
@@ -381,6 +383,9 @@ try_copy_region(struct svga_context *svga,
|
||||
blit->dst.level, dst_face,
|
||||
blit->src.box.width, blit->src.box.height,
|
||||
blit->src.box.depth);
|
||||
|
||||
svga_toggle_render_condition(svga, blit->render_condition_enable, TRUE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -511,8 +516,6 @@ try_blit(struct svga_context *svga, const struct pipe_blit_info *blit_info)
|
||||
util_blitter_save_fragment_sampler_views(svga->blitter,
|
||||
svga->curr.num_sampler_views[PIPE_SHADER_FRAGMENT],
|
||||
svga->curr.sampler_views[PIPE_SHADER_FRAGMENT]);
|
||||
/*util_blitter_save_render_condition(svga->blitter, svga->render_cond_query,
|
||||
svga->render_cond_cond, svga->render_cond_mode);*/
|
||||
|
||||
if (!can_create_src_view) {
|
||||
struct pipe_resource template;
|
||||
@@ -574,8 +577,12 @@ try_blit(struct svga_context *svga, const struct pipe_blit_info *blit_info)
|
||||
blit.dst.resource = newDst;
|
||||
}
|
||||
|
||||
svga_toggle_render_condition(svga, blit.render_condition_enable, FALSE);
|
||||
|
||||
util_blitter_blit(svga->blitter, &blit);
|
||||
|
||||
svga_toggle_render_condition(svga, blit.render_condition_enable, TRUE);
|
||||
|
||||
if (blit.dst.resource != dst) {
|
||||
struct pipe_blit_info copy_region_blit;
|
||||
|
||||
@@ -619,6 +626,13 @@ try_cpu_copy_region(struct svga_context *svga,
|
||||
{
|
||||
if (util_can_blit_via_copy_region(blit, TRUE) ||
|
||||
util_can_blit_via_copy_region(blit, FALSE)) {
|
||||
|
||||
if (svga->render_condition && blit->render_condition_enable) {
|
||||
debug_warning("CPU copy_region doesn't support "
|
||||
"conditional rendering.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
copy_region_fallback(svga, blit->dst.resource,
|
||||
blit->dst.level,
|
||||
blit->dst.box.x, blit->dst.box.y,
|
||||
|
||||
@@ -504,44 +504,6 @@ svga_blitter_clear_render_target(struct svga_context *svga,
|
||||
dstx, dsty, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Toggle conditional rendering if already enabled
|
||||
*
|
||||
* \param svga[in] The svga context
|
||||
* \param render_condition_enabled[in] Whether to ignore requests to turn
|
||||
* conditional rendering off
|
||||
* \param on[in] Whether to turn conditional rendering on or off
|
||||
*/
|
||||
static void
|
||||
svga_toggle_render_condition(struct svga_context *svga,
|
||||
boolean render_condition_enabled,
|
||||
boolean on)
|
||||
{
|
||||
SVGA3dQueryId query_id;
|
||||
enum pipe_error ret;
|
||||
|
||||
if (render_condition_enabled ||
|
||||
svga->pred.query_id == SVGA3D_INVALID_ID) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we get here, it means that the system supports
|
||||
* conditional rendering since svga->pred.query_id has already been
|
||||
* modified for this context and thus support has already been
|
||||
* verified.
|
||||
*/
|
||||
query_id = on ? svga->pred.query_id : SVGA3D_INVALID_ID;
|
||||
|
||||
ret = SVGA3D_vgpu10_SetPredication(svga->swc, query_id,
|
||||
(uint32) svga->pred.cond);
|
||||
if (ret == PIPE_ERROR_OUT_OF_MEMORY) {
|
||||
svga_context_flush(svga, NULL);
|
||||
ret = SVGA3D_vgpu10_SetPredication(svga->swc, query_id,
|
||||
(uint32) svga->pred.cond);
|
||||
assert(ret == PIPE_OK);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Clear render target pipe callback
|
||||
|
||||
@@ -1272,6 +1272,46 @@ svga_set_active_query_state(struct pipe_context *pipe, boolean enable)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Toggle conditional rendering if already enabled
|
||||
*
|
||||
* \param svga[in] The svga context
|
||||
* \param render_condition_enabled[in] Whether to ignore requests to turn
|
||||
* conditional rendering off
|
||||
* \param on[in] Whether to turn conditional rendering on or off
|
||||
*/
|
||||
void
|
||||
svga_toggle_render_condition(struct svga_context *svga,
|
||||
boolean render_condition_enabled,
|
||||
boolean on)
|
||||
{
|
||||
SVGA3dQueryId query_id;
|
||||
enum pipe_error ret;
|
||||
|
||||
if (render_condition_enabled ||
|
||||
svga->pred.query_id == SVGA3D_INVALID_ID) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we get here, it means that the system supports
|
||||
* conditional rendering since svga->pred.query_id has already been
|
||||
* modified for this context and thus support has already been
|
||||
* verified.
|
||||
*/
|
||||
query_id = on ? svga->pred.query_id : SVGA3D_INVALID_ID;
|
||||
|
||||
ret = SVGA3D_vgpu10_SetPredication(svga->swc, query_id,
|
||||
(uint32) svga->pred.cond);
|
||||
if (ret == PIPE_ERROR_OUT_OF_MEMORY) {
|
||||
svga_context_flush(svga, NULL);
|
||||
ret = SVGA3D_vgpu10_SetPredication(svga->swc, query_id,
|
||||
(uint32) svga->pred.cond);
|
||||
assert(ret == PIPE_OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
svga_init_query_functions(struct svga_context *svga)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user