mesa/st: merge transform feedback code from st into mesa
After the objects are merged, this moves the rest of the code from the state tracker into mesa. Acked-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14327>
This commit is contained in:
parent
ecb99724a3
commit
0fb946da94
|
@ -47,9 +47,9 @@
|
|||
#include "util/u_memory.h"
|
||||
#include "util/u_inlines.h"
|
||||
|
||||
#include "state_tracker/st_cb_xformfb.h"
|
||||
#include "api_exec_decl.h"
|
||||
|
||||
#include "cso_cache/cso_context.h"
|
||||
struct using_program_tuple
|
||||
{
|
||||
struct gl_program *prog;
|
||||
|
@ -421,7 +421,46 @@ begin_transform_feedback(struct gl_context *ctx, GLenum mode, bool no_error)
|
|||
obj->program = source;
|
||||
}
|
||||
|
||||
st_begin_transform_feedback(ctx, mode, obj);
|
||||
struct pipe_context *pipe = ctx->pipe;
|
||||
unsigned max_num_targets;
|
||||
unsigned offsets[PIPE_MAX_SO_BUFFERS] = {0};
|
||||
|
||||
max_num_targets = MIN2(ARRAY_SIZE(obj->Buffers),
|
||||
ARRAY_SIZE(obj->targets));
|
||||
|
||||
/* Convert the transform feedback state into the gallium representation. */
|
||||
for (i = 0; i < max_num_targets; i++) {
|
||||
struct gl_buffer_object *bo = obj->Buffers[i];
|
||||
|
||||
if (bo && bo->buffer) {
|
||||
unsigned stream = obj->program->sh.LinkedTransformFeedback->
|
||||
Buffers[i].Stream;
|
||||
|
||||
/* Check whether we need to recreate the target. */
|
||||
if (!obj->targets[i] ||
|
||||
obj->targets[i] == obj->draw_count[stream] ||
|
||||
obj->targets[i]->buffer != bo->buffer ||
|
||||
obj->targets[i]->buffer_offset != obj->Offset[i] ||
|
||||
obj->targets[i]->buffer_size != obj->Size[i]) {
|
||||
/* Create a new target. */
|
||||
struct pipe_stream_output_target *so_target =
|
||||
pipe->create_stream_output_target(pipe, bo->buffer,
|
||||
obj->Offset[i],
|
||||
obj->Size[i]);
|
||||
|
||||
pipe_so_target_reference(&obj->targets[i], NULL);
|
||||
obj->targets[i] = so_target;
|
||||
}
|
||||
|
||||
obj->num_targets = i+1;
|
||||
} else {
|
||||
pipe_so_target_reference(&obj->targets[i], NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/* Start writing at the beginning of each target. */
|
||||
cso_set_stream_outputs(ctx->cso_context, obj->num_targets,
|
||||
obj->targets, offsets);
|
||||
_mesa_update_valid_to_render_state(ctx);
|
||||
}
|
||||
|
||||
|
@ -446,9 +485,30 @@ static void
|
|||
end_transform_feedback(struct gl_context *ctx,
|
||||
struct gl_transform_feedback_object *obj)
|
||||
{
|
||||
unsigned i;
|
||||
FLUSH_VERTICES(ctx, 0, 0);
|
||||
|
||||
st_end_transform_feedback(ctx, obj);
|
||||
cso_set_stream_outputs(ctx->cso_context, 0, NULL, NULL);
|
||||
|
||||
/* The next call to glDrawTransformFeedbackStream should use the vertex
|
||||
* count from the last call to glEndTransformFeedback.
|
||||
* Therefore, save the targets for each stream.
|
||||
*
|
||||
* NULL means the vertex counter is 0 (initial state).
|
||||
*/
|
||||
for (i = 0; i < ARRAY_SIZE(obj->draw_count); i++)
|
||||
pipe_so_target_reference(&obj->draw_count[i], NULL);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(obj->targets); i++) {
|
||||
unsigned stream = obj->program->sh.LinkedTransformFeedback->
|
||||
Buffers[i].Stream;
|
||||
|
||||
/* Is it not bound or already set for this stream? */
|
||||
if (!obj->targets[i] || obj->draw_count[stream])
|
||||
continue;
|
||||
|
||||
pipe_so_target_reference(&obj->draw_count[stream], obj->targets[i]);
|
||||
}
|
||||
|
||||
_mesa_reference_program_(ctx, &obj->program, NULL);
|
||||
ctx->TransformFeedback.CurrentObject->Active = GL_FALSE;
|
||||
|
@ -1190,7 +1250,7 @@ pause_transform_feedback(struct gl_context *ctx,
|
|||
{
|
||||
FLUSH_VERTICES(ctx, 0, 0);
|
||||
|
||||
st_pause_transform_feedback(ctx, obj);
|
||||
cso_set_stream_outputs(ctx->cso_context, 0, NULL, NULL);
|
||||
|
||||
obj->Paused = GL_TRUE;
|
||||
_mesa_update_valid_to_render_state(ctx);
|
||||
|
@ -1235,7 +1295,14 @@ resume_transform_feedback(struct gl_context *ctx,
|
|||
|
||||
obj->Paused = GL_FALSE;
|
||||
|
||||
st_resume_transform_feedback(ctx, obj);
|
||||
unsigned offsets[PIPE_MAX_SO_BUFFERS];
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < PIPE_MAX_SO_BUFFERS; i++)
|
||||
offsets[i] = (unsigned)-1;
|
||||
|
||||
cso_set_stream_outputs(ctx->cso_context, obj->num_targets,
|
||||
obj->targets, offsets);
|
||||
_mesa_update_valid_to_render_state(ctx);
|
||||
}
|
||||
|
||||
|
|
|
@ -356,8 +356,6 @@ files_libmesa = files(
|
|||
'state_tracker/st_cb_texture.h',
|
||||
'state_tracker/st_cb_viewport.c',
|
||||
'state_tracker/st_cb_viewport.h',
|
||||
'state_tracker/st_cb_xformfb.c',
|
||||
'state_tracker/st_cb_xformfb.h',
|
||||
'state_tracker/st_context.c',
|
||||
'state_tracker/st_context.h',
|
||||
'state_tracker/st_copytex.c',
|
||||
|
|
|
@ -1,163 +0,0 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2010 VMware, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* Transform feedback functions.
|
||||
*
|
||||
* \author Brian Paul
|
||||
* Marek Olšák
|
||||
*/
|
||||
|
||||
|
||||
#include "main/bufferobj.h"
|
||||
#include "main/context.h"
|
||||
#include "main/transformfeedback.h"
|
||||
#include "util/u_memory.h"
|
||||
|
||||
#include "st_cb_xformfb.h"
|
||||
#include "st_context.h"
|
||||
|
||||
#include "pipe/p_context.h"
|
||||
#include "util/u_draw.h"
|
||||
#include "util/u_inlines.h"
|
||||
#include "cso_cache/cso_context.h"
|
||||
|
||||
|
||||
|
||||
/* XXX Do we really need the mode? */
|
||||
void
|
||||
st_begin_transform_feedback(struct gl_context *ctx, GLenum mode,
|
||||
struct gl_transform_feedback_object *obj)
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct pipe_context *pipe = ctx->pipe;
|
||||
unsigned i, max_num_targets;
|
||||
unsigned offsets[PIPE_MAX_SO_BUFFERS] = {0};
|
||||
|
||||
max_num_targets = MIN2(ARRAY_SIZE(obj->Buffers),
|
||||
ARRAY_SIZE(obj->targets));
|
||||
|
||||
/* Convert the transform feedback state into the gallium representation. */
|
||||
for (i = 0; i < max_num_targets; i++) {
|
||||
struct gl_buffer_object *bo = obj->Buffers[i];
|
||||
|
||||
if (bo && bo->buffer) {
|
||||
unsigned stream = obj->program->sh.LinkedTransformFeedback->
|
||||
Buffers[i].Stream;
|
||||
|
||||
/* Check whether we need to recreate the target. */
|
||||
if (!obj->targets[i] ||
|
||||
obj->targets[i] == obj->draw_count[stream] ||
|
||||
obj->targets[i]->buffer != bo->buffer ||
|
||||
obj->targets[i]->buffer_offset != obj->Offset[i] ||
|
||||
obj->targets[i]->buffer_size != obj->Size[i]) {
|
||||
/* Create a new target. */
|
||||
struct pipe_stream_output_target *so_target =
|
||||
pipe->create_stream_output_target(pipe, bo->buffer,
|
||||
obj->Offset[i],
|
||||
obj->Size[i]);
|
||||
|
||||
pipe_so_target_reference(&obj->targets[i], NULL);
|
||||
obj->targets[i] = so_target;
|
||||
}
|
||||
|
||||
obj->num_targets = i+1;
|
||||
} else {
|
||||
pipe_so_target_reference(&obj->targets[i], NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/* Start writing at the beginning of each target. */
|
||||
cso_set_stream_outputs(st->cso_context, obj->num_targets,
|
||||
obj->targets, offsets);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
st_pause_transform_feedback(struct gl_context *ctx,
|
||||
struct gl_transform_feedback_object *obj)
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
cso_set_stream_outputs(st->cso_context, 0, NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
st_resume_transform_feedback(struct gl_context *ctx,
|
||||
struct gl_transform_feedback_object *obj)
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
unsigned offsets[PIPE_MAX_SO_BUFFERS];
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < PIPE_MAX_SO_BUFFERS; i++)
|
||||
offsets[i] = (unsigned)-1;
|
||||
|
||||
cso_set_stream_outputs(st->cso_context, obj->num_targets,
|
||||
obj->targets, offsets);
|
||||
}
|
||||
|
||||
void
|
||||
st_end_transform_feedback(struct gl_context *ctx,
|
||||
struct gl_transform_feedback_object *obj)
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
unsigned i;
|
||||
|
||||
cso_set_stream_outputs(st->cso_context, 0, NULL, NULL);
|
||||
|
||||
/* The next call to glDrawTransformFeedbackStream should use the vertex
|
||||
* count from the last call to glEndTransformFeedback.
|
||||
* Therefore, save the targets for each stream.
|
||||
*
|
||||
* NULL means the vertex counter is 0 (initial state).
|
||||
*/
|
||||
for (i = 0; i < ARRAY_SIZE(obj->draw_count); i++)
|
||||
pipe_so_target_reference(&obj->draw_count[i], NULL);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(obj->targets); i++) {
|
||||
unsigned stream = obj->program->sh.LinkedTransformFeedback->
|
||||
Buffers[i].Stream;
|
||||
|
||||
/* Is it not bound or already set for this stream? */
|
||||
if (!obj->targets[i] || obj->draw_count[stream])
|
||||
continue;
|
||||
|
||||
pipe_so_target_reference(&obj->draw_count[stream], obj->targets[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
st_transform_feedback_draw_init(struct gl_transform_feedback_object *obj,
|
||||
unsigned stream,
|
||||
struct pipe_draw_indirect_info *out)
|
||||
{
|
||||
out->count_from_stream_output = obj->draw_count[stream];
|
||||
return out->count_from_stream_output != NULL;
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2010 VMware, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef ST_CB_XFORMFB_H
|
||||
#define ST_CB_XFORMFB_H
|
||||
|
||||
|
||||
struct gl_transform_feedback_object;
|
||||
struct pipe_draw_indirect_info;
|
||||
|
||||
void
|
||||
st_begin_transform_feedback(struct gl_context *ctx, GLenum mode,
|
||||
struct gl_transform_feedback_object *obj);
|
||||
|
||||
void
|
||||
st_pause_transform_feedback(struct gl_context *ctx,
|
||||
struct gl_transform_feedback_object *obj);
|
||||
|
||||
void
|
||||
st_resume_transform_feedback(struct gl_context *ctx,
|
||||
struct gl_transform_feedback_object *obj);
|
||||
|
||||
void
|
||||
st_end_transform_feedback(struct gl_context *ctx,
|
||||
struct gl_transform_feedback_object *obj);
|
||||
|
||||
extern bool
|
||||
st_transform_feedback_draw_init(struct gl_transform_feedback_object *obj,
|
||||
unsigned stream,
|
||||
struct pipe_draw_indirect_info *out);
|
||||
|
||||
|
||||
#endif /* ST_CB_XFORMFB_H */
|
|
@ -50,7 +50,6 @@
|
|||
#include "st_context.h"
|
||||
#include "st_atom.h"
|
||||
#include "st_cb_bitmap.h"
|
||||
#include "st_cb_xformfb.h"
|
||||
#include "st_debug.h"
|
||||
#include "st_draw.h"
|
||||
#include "st_program.h"
|
||||
|
@ -306,7 +305,8 @@ st_draw_transform_feedback(struct gl_context *ctx, GLenum mode,
|
|||
|
||||
/* Transform feedback drawing is always non-indexed. */
|
||||
/* Set info.count_from_stream_output. */
|
||||
if (!st_transform_feedback_draw_init(tfb_vertcount, stream, &indirect))
|
||||
indirect.count_from_stream_output = tfb_vertcount->draw_count[stream];
|
||||
if (indirect.count_from_stream_output == NULL)
|
||||
return;
|
||||
|
||||
cso_draw_vbo(st->cso_context, &info, 0, &indirect, draw);
|
||||
|
|
Loading…
Reference in New Issue