|
|
@@ -4292,7 +4292,7 @@ end_frame(Thread *current_thread) {
|
|
|
bool CLP(GraphicsStateGuardian)::
|
|
|
begin_draw_primitives(const GeomPipelineReader *geom_reader,
|
|
|
const GeomVertexDataPipelineReader *data_reader,
|
|
|
- bool force) {
|
|
|
+ size_t num_instances, bool force) {
|
|
|
#ifndef NDEBUG
|
|
|
if (GLCAT.is_spam()) {
|
|
|
GLCAT.spam() << "begin_draw_primitives: " << *(data_reader->get_object()) << "\n";
|
|
|
@@ -4309,11 +4309,13 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader,
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
- if (!GraphicsStateGuardian::begin_draw_primitives(geom_reader, data_reader, force)) {
|
|
|
+ if (!GraphicsStateGuardian::begin_draw_primitives(geom_reader, data_reader, num_instances, force)) {
|
|
|
return false;
|
|
|
}
|
|
|
nassertr(_data_reader != nullptr, false);
|
|
|
|
|
|
+ _instance_count = _supports_geometry_instancing ? num_instances : 1;
|
|
|
+
|
|
|
_geom_display_list = 0;
|
|
|
|
|
|
if (_auto_antialias_mode) {
|
|
|
@@ -4861,7 +4863,7 @@ draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
}
|
|
|
|
|
|
#ifndef OPENGLES_1
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawElementsInstanced(GL_TRIANGLES, num_vertices,
|
|
|
get_numeric_type(reader->get_index_type()),
|
|
|
client_pointer, _instance_count);
|
|
|
@@ -4877,7 +4879,7 @@ draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
}
|
|
|
} else {
|
|
|
#ifndef OPENGLES_1
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawArraysInstanced(GL_TRIANGLES,
|
|
|
reader->get_first_vertex(),
|
|
|
num_vertices, _instance_count);
|
|
|
@@ -4927,7 +4929,7 @@ draw_triangles_adj(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawElementsInstanced(GL_TRIANGLES_ADJACENCY, num_vertices,
|
|
|
get_numeric_type(reader->get_index_type()),
|
|
|
client_pointer, _instance_count);
|
|
|
@@ -4940,7 +4942,7 @@ draw_triangles_adj(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
client_pointer);
|
|
|
}
|
|
|
} else {
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawArraysInstanced(GL_TRIANGLES_ADJACENCY,
|
|
|
reader->get_first_vertex(),
|
|
|
num_vertices, _instance_count);
|
|
|
@@ -4992,7 +4994,7 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
return false;
|
|
|
}
|
|
|
#ifndef OPENGLES_1
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawElementsInstanced(GL_TRIANGLE_STRIP, num_vertices,
|
|
|
get_numeric_type(reader->get_index_type()),
|
|
|
client_pointer, _instance_count);
|
|
|
@@ -5008,7 +5010,7 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
}
|
|
|
} else {
|
|
|
#ifndef OPENGLES_1
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawArraysInstanced(GL_TRIANGLE_STRIP,
|
|
|
reader->get_first_vertex(),
|
|
|
num_vertices, _instance_count);
|
|
|
@@ -5042,7 +5044,7 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
for (size_t i = 0; i < ends.size(); i++) {
|
|
|
_vertices_tristrip_pcollector.add_level(ends[i] - start);
|
|
|
#ifndef OPENGLES_1
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawElementsInstanced(GL_TRIANGLE_STRIP, ends[i] - start,
|
|
|
get_numeric_type(reader->get_index_type()),
|
|
|
client_pointer + start * index_stride,
|
|
|
@@ -5064,7 +5066,7 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
for (size_t i = 0; i < ends.size(); i++) {
|
|
|
_vertices_tristrip_pcollector.add_level(ends[i] - start);
|
|
|
#ifndef OPENGLES_1
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawArraysInstanced(GL_TRIANGLE_STRIP, first_vertex + start,
|
|
|
ends[i] - start, _instance_count);
|
|
|
} else
|
|
|
@@ -5122,7 +5124,7 @@ draw_tristrips_adj(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
if (!setup_primitive(client_pointer, reader, force)) {
|
|
|
return false;
|
|
|
}
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawElementsInstanced(GL_TRIANGLE_STRIP_ADJACENCY, num_vertices,
|
|
|
get_numeric_type(reader->get_index_type()),
|
|
|
client_pointer, _instance_count);
|
|
|
@@ -5135,7 +5137,7 @@ draw_tristrips_adj(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
client_pointer);
|
|
|
}
|
|
|
} else {
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawArraysInstanced(GL_TRIANGLE_STRIP_ADJACENCY,
|
|
|
reader->get_first_vertex(),
|
|
|
num_vertices, _instance_count);
|
|
|
@@ -5168,7 +5170,7 @@ draw_tristrips_adj(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
unsigned int start = 0;
|
|
|
for (size_t i = 0; i < ends.size(); i++) {
|
|
|
_vertices_tristrip_pcollector.add_level(ends[i] - start);
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawElementsInstanced(GL_TRIANGLE_STRIP_ADJACENCY, ends[i] - start,
|
|
|
get_numeric_type(reader->get_index_type()),
|
|
|
client_pointer + start * index_stride,
|
|
|
@@ -5187,7 +5189,7 @@ draw_tristrips_adj(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
int first_vertex = reader->get_first_vertex();
|
|
|
for (size_t i = 0; i < ends.size(); i++) {
|
|
|
_vertices_tristrip_pcollector.add_level(ends[i] - start);
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawArraysInstanced(GL_TRIANGLE_STRIP_ADJACENCY, first_vertex + start,
|
|
|
ends[i] - start, _instance_count);
|
|
|
} else {
|
|
|
@@ -5245,7 +5247,7 @@ draw_trifans(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
for (size_t i = 0; i < ends.size(); i++) {
|
|
|
_vertices_trifan_pcollector.add_level(ends[i] - start);
|
|
|
#ifndef OPENGLES_1
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawElementsInstanced(GL_TRIANGLE_FAN, ends[i] - start,
|
|
|
get_numeric_type(reader->get_index_type()),
|
|
|
client_pointer + start * index_stride,
|
|
|
@@ -5266,7 +5268,7 @@ draw_trifans(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
for (size_t i = 0; i < ends.size(); i++) {
|
|
|
_vertices_trifan_pcollector.add_level(ends[i] - start);
|
|
|
#ifndef OPENGLES_1
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawArraysInstanced(GL_TRIANGLE_FAN, first_vertex + start,
|
|
|
ends[i] - start, _instance_count);
|
|
|
} else
|
|
|
@@ -5324,7 +5326,7 @@ draw_patches(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
}
|
|
|
|
|
|
#ifndef OPENGLES_1
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawElementsInstanced(GL_PATCHES, num_vertices,
|
|
|
get_numeric_type(reader->get_index_type()),
|
|
|
client_pointer, _instance_count);
|
|
|
@@ -5340,7 +5342,7 @@ draw_patches(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
}
|
|
|
} else {
|
|
|
#ifndef OPENGLES_1
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawArraysInstanced(GL_PATCHES,
|
|
|
reader->get_first_vertex(),
|
|
|
num_vertices, _instance_count);
|
|
|
@@ -5390,7 +5392,7 @@ draw_lines(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
return false;
|
|
|
}
|
|
|
#ifndef OPENGLES_1
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawElementsInstanced(GL_LINES, num_vertices,
|
|
|
get_numeric_type(reader->get_index_type()),
|
|
|
client_pointer, _instance_count);
|
|
|
@@ -5406,7 +5408,7 @@ draw_lines(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
}
|
|
|
} else {
|
|
|
#ifndef OPENGLES_1
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawArraysInstanced(GL_LINES,
|
|
|
reader->get_first_vertex(),
|
|
|
num_vertices, _instance_count);
|
|
|
@@ -5454,7 +5456,7 @@ draw_lines_adj(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
if (!setup_primitive(client_pointer, reader, force)) {
|
|
|
return false;
|
|
|
}
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawElementsInstanced(GL_LINES_ADJACENCY, num_vertices,
|
|
|
get_numeric_type(reader->get_index_type()),
|
|
|
client_pointer, _instance_count);
|
|
|
@@ -5467,7 +5469,7 @@ draw_lines_adj(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
client_pointer);
|
|
|
}
|
|
|
} else {
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawArraysInstanced(GL_LINES_ADJACENCY,
|
|
|
reader->get_first_vertex(),
|
|
|
num_vertices, _instance_count);
|
|
|
@@ -5526,7 +5528,7 @@ draw_linestrips(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
return false;
|
|
|
}
|
|
|
#ifndef OPENGLES_1
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawElementsInstanced(GL_LINE_STRIP, num_vertices,
|
|
|
get_numeric_type(reader->get_index_type()),
|
|
|
client_pointer, _instance_count);
|
|
|
@@ -5566,7 +5568,7 @@ draw_linestrips(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
for (size_t i = 0; i < ends.size(); i++) {
|
|
|
_vertices_other_pcollector.add_level(ends[i] - start);
|
|
|
#ifndef OPENGLES_1
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawElementsInstanced(GL_LINE_STRIP, ends[i] - start,
|
|
|
get_numeric_type(reader->get_index_type()),
|
|
|
client_pointer + start * index_stride,
|
|
|
@@ -5588,7 +5590,7 @@ draw_linestrips(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
for (size_t i = 0; i < ends.size(); i++) {
|
|
|
_vertices_other_pcollector.add_level(ends[i] - start);
|
|
|
#ifndef OPENGLES_1
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawArraysInstanced(GL_LINE_STRIP, first_vertex + start,
|
|
|
ends[i] - start, _instance_count);
|
|
|
} else
|
|
|
@@ -5646,7 +5648,7 @@ draw_linestrips_adj(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
if (!setup_primitive(client_pointer, reader, force)) {
|
|
|
return false;
|
|
|
}
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawElementsInstanced(GL_LINE_STRIP_ADJACENCY, num_vertices,
|
|
|
get_numeric_type(reader->get_index_type()),
|
|
|
client_pointer, _instance_count);
|
|
|
@@ -5681,7 +5683,7 @@ draw_linestrips_adj(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
unsigned int start = 0;
|
|
|
for (size_t i = 0; i < ends.size(); i++) {
|
|
|
_vertices_other_pcollector.add_level(ends[i] - start);
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawElementsInstanced(GL_LINE_STRIP_ADJACENCY, ends[i] - start,
|
|
|
get_numeric_type(reader->get_index_type()),
|
|
|
client_pointer + start * index_stride,
|
|
|
@@ -5700,7 +5702,7 @@ draw_linestrips_adj(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
int first_vertex = reader->get_first_vertex();
|
|
|
for (size_t i = 0; i < ends.size(); i++) {
|
|
|
_vertices_other_pcollector.add_level(ends[i] - start);
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawArraysInstanced(GL_LINE_STRIP_ADJACENCY, first_vertex + start,
|
|
|
ends[i] - start, _instance_count);
|
|
|
} else {
|
|
|
@@ -5747,7 +5749,7 @@ draw_points(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
return false;
|
|
|
}
|
|
|
#ifndef OPENGLES_1
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawElementsInstanced(GL_POINTS, num_vertices,
|
|
|
get_numeric_type(reader->get_index_type()),
|
|
|
client_pointer, _instance_count);
|
|
|
@@ -5763,7 +5765,7 @@ draw_points(const GeomPrimitivePipelineReader *reader, bool force) {
|
|
|
}
|
|
|
} else {
|
|
|
#ifndef OPENGLES_1
|
|
|
- if (_supports_geometry_instancing && _instance_count > 0) {
|
|
|
+ if (_instance_count != 1) {
|
|
|
_glDrawArraysInstanced(GL_POINTS,
|
|
|
reader->get_first_vertex(),
|
|
|
num_vertices, _instance_count);
|
|
|
@@ -11444,7 +11446,7 @@ set_state_and_transform(const RenderState *target,
|
|
|
|
|
|
#ifndef OPENGLES_1
|
|
|
determine_target_shader();
|
|
|
- _instance_count = _target_shader->get_instance_count();
|
|
|
+ _sattr_instance_count = _target_shader->get_instance_count();
|
|
|
|
|
|
if (_target_shader != _state_shader) {
|
|
|
do_issue_shader();
|