Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2022-08-27 16:49:06 +0300
committerClément Foucault <foucault.clem@gmail.com>2022-08-27 16:49:06 +0300
commit48e773ca407bf2bdc9d181cd486f38ee281fe5ea (patch)
treee3ecc248b479f68c031aa2d714951941025dc091
parent8814a0f699b623505e5f223d05d1dc3d5913c5cb (diff)
Fix different mesh rendering
-rw-r--r--source/blender/draw/intern/draw_command.cc25
-rw-r--r--source/blender/draw/intern/draw_command_shared.hh29
2 files changed, 22 insertions, 32 deletions
diff --git a/source/blender/draw/intern/draw_command.cc b/source/blender/draw/intern/draw_command.cc
index 004cf0d5c02..17f09db78f2 100644
--- a/source/blender/draw/intern/draw_command.cc
+++ b/source/blender/draw/intern/draw_command.cc
@@ -87,10 +87,7 @@ void DrawMulti::execute(RecordingState &state) const
while (group_index != (uint)-1) {
const DrawGroup &grp = groups[group_index];
- /** IMPORTANT: We cannot use grp.gpu_batch here since it has been overriden by the atomic
- * counters. Use the DrawMulti.batch instead. */
-
- GPU_batch_set_shader(batch, state.shader);
+ GPU_batch_set_shader(grp.gpu_batch, state.shader);
constexpr intptr_t stride = sizeof(DrawCommand);
/* We have 2 indirect command reserved per draw group. */
@@ -99,12 +96,12 @@ void DrawMulti::execute(RecordingState &state) const
/* Draw negatively scaled geometry first. */
if (grp.len - grp.front_facing_len > 0) {
state.front_facing_set(false);
- GPU_batch_draw_indirect(batch, indirect_buf, offset);
+ GPU_batch_draw_indirect(grp.gpu_batch, indirect_buf, offset);
}
if (grp.front_facing_len > 0) {
state.front_facing_set(true);
- GPU_batch_draw_indirect(batch, indirect_buf, offset + stride);
+ GPU_batch_draw_indirect(grp.gpu_batch, indirect_buf, offset + stride);
}
group_index = grp.next;
@@ -379,9 +376,9 @@ std::string DrawMulti::serialize(std::string line_prefix) const
if (grp.back_proto_len > 0) {
for (DrawPrototype &proto : prototypes.slice({offset, grp.back_proto_len})) {
- // BLI_assert(proto.group_id == group_index);
+ BLI_assert(proto.group_id == group_index);
ResourceHandle handle(proto.resource_handle);
- // BLI_assert(handle.has_inverted_handedness());
+ BLI_assert(handle.has_inverted_handedness());
ss << std::endl
<< line_prefix << " .proto(instance_len=" << std::to_string(proto.instance_len)
<< ", resource_id=" << std::to_string(handle.resource_index()) << ", back_face)";
@@ -391,9 +388,9 @@ std::string DrawMulti::serialize(std::string line_prefix) const
if (grp.front_proto_len > 0) {
for (DrawPrototype &proto : prototypes.slice({offset, grp.front_proto_len})) {
- // BLI_assert(proto.group_id == group_index);
+ BLI_assert(proto.group_id == group_index);
ResourceHandle handle(proto.resource_handle);
- // BLI_assert(!handle.has_inverted_handedness());
+ BLI_assert(!handle.has_inverted_handedness());
ss << std::endl
<< line_prefix << " .proto(instance_len=" << std::to_string(proto.instance_len)
<< ", resource_id=" << std::to_string(handle.resource_index()) << ", front_face)";
@@ -538,18 +535,12 @@ void DrawMultiBuf::bind(RecordingState &state,
group.start = resource_id_count_;
resource_id_count_ += group.len;
- /* Need to do this before group.gpu_batch is mangled. */
- bool is_indexed = (group.gpu_batch->elem != nullptr);
-
int batch_inst_len;
/* Now that GPUBatches are guaranteed to be finished, extract their parameters. */
- /** WATCH: group.vertex_len and group.gpu_batch are in the same union.
- * group.gpu_batch is not valid after this point. This is still ok to call this since the
- * pointer is passed by value. */
GPU_batch_draw_parameter_get(group.gpu_batch, &group.vertex_len, &batch_inst_len);
/* Tag group as using index draw (changes indirect draw call structure). */
- if (is_indexed) {
+ if (group.gpu_batch->elem != nullptr) {
group.vertex_len = -group.vertex_len;
}
diff --git a/source/blender/draw/intern/draw_command_shared.hh b/source/blender/draw/intern/draw_command_shared.hh
index afd3e06deb7..f412e609fbe 100644
--- a/source/blender/draw/intern/draw_command_shared.hh
+++ b/source/blender/draw/intern/draw_command_shared.hh
@@ -34,26 +34,25 @@ struct DrawGroup {
/** Number of non inverted scaling instances in this Group. */
uint front_facing_len;
+ /** GPUBatch values to be copied to DrawCommand after sorting (if not overriden). */
+ int vertex_len; /** NOTE: Negative if using indexed draw. */
+ /** Atomic counters used during command sorting. */
+ uint front_facing_counter;
+ uint back_facing_counter;
+ uint total_counter;
+
+ /** For debug printing only. */
+ uint front_proto_len;
+ uint back_proto_len;
+
#ifndef GPU_SHADER
/* NOTE: Union just to make sure the struct has always the same size on all platform. */
union {
- struct {
- /** Needed to create the correct draw call. Deleted before upload. */
- GPUBatch *gpu_batch;
- /** For debugging only */
- uint front_proto_len;
- uint back_proto_len;
- };
- struct {
+ /** Needed to create the correct draw call. */
+ GPUBatch *gpu_batch;
#endif
- /** GPUBatch values to be copied to DrawCommand after sorting (if not overriden). */
- int vertex_len; /** NOTE: Negative if using indexed draw. */
- /** Atomic counters used during command sorting. */
- uint front_facing_counter;
- uint back_facing_counter;
- uint total_counter;
+ uint2 _pad0;
#ifndef GPU_SHADER
- };
};
#endif
};