DRW: Add support for clip plane count as part of the draw state.
This moves the implementation from the View to the draw manager itself. However, this is not its final place and should be moved to the shader create info at some point in the future. For now it is not possible because of possible interaction with the old draw manager codebase.
This commit is contained in:
@@ -166,7 +166,8 @@ void StateSet::execute(RecordingState &recording_state) const
|
|||||||
*/
|
*/
|
||||||
BLI_assert(DST.state_lock == 0);
|
BLI_assert(DST.state_lock == 0);
|
||||||
|
|
||||||
if (!assign_if_different(recording_state.pipeline_state, new_state)) {
|
if (!assign_if_different(recording_state.pipeline_state, new_state) &&
|
||||||
|
!assign_if_different(recording_state.clip_plane_count, clip_plane_count)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,12 +191,7 @@ void StateSet::execute(RecordingState &recording_state) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: this should be part of shader state. */
|
/* TODO: this should be part of shader state. */
|
||||||
if (new_state & DRW_STATE_CLIP_PLANES) {
|
GPU_clip_distances(recording_state.clip_plane_count);
|
||||||
GPU_clip_distances(recording_state.view_clip_plane_count);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
GPU_clip_distances(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (new_state & DRW_STATE_IN_FRONT_SELECT) {
|
if (new_state & DRW_STATE_IN_FRONT_SELECT) {
|
||||||
/* XXX `GPU_depth_range` is not a perfect solution
|
/* XXX `GPU_depth_range` is not a perfect solution
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ struct RecordingState {
|
|||||||
bool front_facing = true;
|
bool front_facing = true;
|
||||||
bool inverted_view = false;
|
bool inverted_view = false;
|
||||||
DRWState pipeline_state = DRW_STATE_NO_DRAW;
|
DRWState pipeline_state = DRW_STATE_NO_DRAW;
|
||||||
int view_clip_plane_count = 0;
|
int clip_plane_count = 0;
|
||||||
/** Used for gl_BaseInstance workaround. */
|
/** Used for gl_BaseInstance workaround. */
|
||||||
GPUStorageBuf *resource_id_buf = nullptr;
|
GPUStorageBuf *resource_id_buf = nullptr;
|
||||||
|
|
||||||
@@ -325,6 +325,7 @@ struct Clear {
|
|||||||
|
|
||||||
struct StateSet {
|
struct StateSet {
|
||||||
DRWState new_state;
|
DRWState new_state;
|
||||||
|
int clip_plane_count;
|
||||||
|
|
||||||
void execute(RecordingState &state) const;
|
void execute(RecordingState &state) const;
|
||||||
std::string serialize() const;
|
std::string serialize() const;
|
||||||
|
|||||||
@@ -159,8 +159,10 @@ class PassBase {
|
|||||||
*
|
*
|
||||||
* IMPORTANT: This does not set the stencil mask/reference values. Add a call to state_stencil()
|
* IMPORTANT: This does not set the stencil mask/reference values. Add a call to state_stencil()
|
||||||
* to ensure correct behavior of stencil aware draws.
|
* to ensure correct behavior of stencil aware draws.
|
||||||
|
*
|
||||||
|
* TODO(fclem): clip_plane_count should be part of shader state.
|
||||||
*/
|
*/
|
||||||
void state_set(DRWState state);
|
void state_set(DRWState state, int clip_plane_count = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the current frame-buffer.
|
* Clear the current frame-buffer.
|
||||||
@@ -731,9 +733,13 @@ template<class T> inline void PassBase<T>::barrier(eGPUBarrier type)
|
|||||||
/** \name State Implementation
|
/** \name State Implementation
|
||||||
* \{ */
|
* \{ */
|
||||||
|
|
||||||
template<class T> inline void PassBase<T>::state_set(DRWState state)
|
template<class T> inline void PassBase<T>::state_set(DRWState state, int clip_plane_count)
|
||||||
{
|
{
|
||||||
create_command(Type::StateSet).state_set = {state};
|
/** \note This is for compatibility with the old clip plane API. */
|
||||||
|
if (clip_plane_count > 0) {
|
||||||
|
state |= DRW_STATE_CLIP_PLANES;
|
||||||
|
}
|
||||||
|
create_command(Type::StateSet).state_set = {state, clip_plane_count};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|||||||
Reference in New Issue
Block a user