|
|
@@ -609,10 +609,10 @@ reset() {
|
|
|
GraphicsStateGuardian::reset();
|
|
|
|
|
|
// Build _inv_state_mask as a mask of 1's where we don't care, and 0's where
|
|
|
- // we do care, about the state. _inv_state_mask =
|
|
|
- // RenderState::SlotMask::all_on();
|
|
|
+ // we do care, about the state.
|
|
|
+#ifndef OPENGLES_1
|
|
|
_inv_state_mask.clear_bit(ShaderAttrib::get_class_slot());
|
|
|
- _inv_state_mask.clear_bit(AlphaTestAttrib::get_class_slot());
|
|
|
+#endif
|
|
|
_inv_state_mask.clear_bit(AntialiasAttrib::get_class_slot());
|
|
|
_inv_state_mask.clear_bit(ClipPlaneAttrib::get_class_slot());
|
|
|
_inv_state_mask.clear_bit(ColorAttrib::get_class_slot());
|
|
|
@@ -622,21 +622,30 @@ reset() {
|
|
|
_inv_state_mask.clear_bit(DepthTestAttrib::get_class_slot());
|
|
|
_inv_state_mask.clear_bit(DepthWriteAttrib::get_class_slot());
|
|
|
_inv_state_mask.clear_bit(RenderModeAttrib::get_class_slot());
|
|
|
- _inv_state_mask.clear_bit(RescaleNormalAttrib::get_class_slot());
|
|
|
- _inv_state_mask.clear_bit(ShadeModelAttrib::get_class_slot());
|
|
|
_inv_state_mask.clear_bit(TransparencyAttrib::get_class_slot());
|
|
|
_inv_state_mask.clear_bit(ColorWriteAttrib::get_class_slot());
|
|
|
_inv_state_mask.clear_bit(ColorBlendAttrib::get_class_slot());
|
|
|
+#if !defined(OPENGLES) || defined(OPENGLES_1)
|
|
|
_inv_state_mask.clear_bit(LogicOpAttrib::get_class_slot());
|
|
|
+#endif
|
|
|
_inv_state_mask.clear_bit(TextureAttrib::get_class_slot());
|
|
|
- _inv_state_mask.clear_bit(TexGenAttrib::get_class_slot());
|
|
|
_inv_state_mask.clear_bit(TexMatrixAttrib::get_class_slot());
|
|
|
- _inv_state_mask.clear_bit(MaterialAttrib::get_class_slot());
|
|
|
- _inv_state_mask.clear_bit(LightAttrib::get_class_slot());
|
|
|
_inv_state_mask.clear_bit(StencilAttrib::get_class_slot());
|
|
|
- _inv_state_mask.clear_bit(FogAttrib::get_class_slot());
|
|
|
_inv_state_mask.clear_bit(ScissorAttrib::get_class_slot());
|
|
|
|
|
|
+ // We only care about this state if we are using the fixed-function pipeline.
|
|
|
+#ifdef SUPPORT_FIXED_FUNCTION
|
|
|
+ if (has_fixed_function_pipeline()) {
|
|
|
+ _inv_state_mask.clear_bit(AlphaTestAttrib::get_class_slot());
|
|
|
+ _inv_state_mask.clear_bit(RescaleNormalAttrib::get_class_slot());
|
|
|
+ _inv_state_mask.clear_bit(ShadeModelAttrib::get_class_slot());
|
|
|
+ _inv_state_mask.clear_bit(TexGenAttrib::get_class_slot());
|
|
|
+ _inv_state_mask.clear_bit(MaterialAttrib::get_class_slot());
|
|
|
+ _inv_state_mask.clear_bit(LightAttrib::get_class_slot());
|
|
|
+ _inv_state_mask.clear_bit(FogAttrib::get_class_slot());
|
|
|
+ }
|
|
|
+#endif
|
|
|
+
|
|
|
// Output the vendor and version strings.
|
|
|
query_gl_version();
|
|
|
|
|
|
@@ -1923,6 +1932,8 @@ reset() {
|
|
|
get_extension_func("glUniform3uiv");
|
|
|
_glUniform4uiv = (PFNGLUNIFORM4UIVPROC)
|
|
|
get_extension_func("glUniform4uiv");
|
|
|
+ _glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC)
|
|
|
+ get_extension_func("glVertexAttribI4ui");
|
|
|
|
|
|
} else if (has_extension("GL_EXT_gpu_shader4")) {
|
|
|
_glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC)
|
|
|
@@ -1937,10 +1948,13 @@ reset() {
|
|
|
get_extension_func("glUniform3uivEXT");
|
|
|
_glUniform4uiv = (PFNGLUNIFORM4UIVPROC)
|
|
|
get_extension_func("glUniform4uivEXT");
|
|
|
+ _glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC)
|
|
|
+ get_extension_func("glVertexAttribI4uiEXT");
|
|
|
|
|
|
} else {
|
|
|
_glBindFragDataLocation = nullptr;
|
|
|
_glVertexAttribIPointer = nullptr;
|
|
|
+ _glVertexAttribI4ui = nullptr;
|
|
|
}
|
|
|
if (is_at_least_gl_version(4, 1) ||
|
|
|
has_extension("GL_ARB_vertex_attrib_64bit")) {
|
|
|
@@ -1969,8 +1983,11 @@ reset() {
|
|
|
get_extension_func("glVertexAttribPointerARB");
|
|
|
|
|
|
_glBindFragDataLocation = nullptr;
|
|
|
+ _glVertexAttribI4ui = nullptr;
|
|
|
_glVertexAttribIPointer = nullptr;
|
|
|
_glVertexAttribLPointer = nullptr;
|
|
|
+ } else {
|
|
|
+ _glVertexAttribI4ui = nullptr;
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
@@ -2017,8 +2034,11 @@ reset() {
|
|
|
if (is_at_least_gles_version(3, 0)) {
|
|
|
_glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)
|
|
|
get_extension_func("glVertexAttribIPointer");
|
|
|
+ _glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC)
|
|
|
+ get_extension_func("glVertexAttribI4ui");
|
|
|
} else {
|
|
|
_glVertexAttribIPointer = nullptr;
|
|
|
+ _glVertexAttribI4ui = nullptr;
|
|
|
}
|
|
|
|
|
|
if (has_extension("GL_EXT_blend_func_extended")) {
|
|
|
@@ -4290,7 +4310,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";
|
|
|
@@ -4307,11 +4327,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) {
|
|
|
@@ -4859,7 +4881,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);
|
|
|
@@ -4875,7 +4897,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);
|
|
|
@@ -4925,7 +4947,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);
|
|
|
@@ -4938,7 +4960,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);
|
|
|
@@ -4990,7 +5012,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);
|
|
|
@@ -5006,7 +5028,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);
|
|
|
@@ -5040,7 +5062,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,
|
|
|
@@ -5062,7 +5084,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
|
|
|
@@ -5120,7 +5142,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);
|
|
|
@@ -5133,7 +5155,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);
|
|
|
@@ -5166,7 +5188,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,
|
|
|
@@ -5185,7 +5207,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 {
|
|
|
@@ -5243,7 +5265,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,
|
|
|
@@ -5264,7 +5286,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
|
|
|
@@ -5322,7 +5344,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);
|
|
|
@@ -5338,7 +5360,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);
|
|
|
@@ -5388,7 +5410,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);
|
|
|
@@ -5404,7 +5426,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);
|
|
|
@@ -5452,7 +5474,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);
|
|
|
@@ -5465,7 +5487,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);
|
|
|
@@ -5524,7 +5546,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);
|
|
|
@@ -5564,7 +5586,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,
|
|
|
@@ -5586,7 +5608,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
|
|
|
@@ -5644,7 +5666,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);
|
|
|
@@ -5679,7 +5701,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,
|
|
|
@@ -5698,7 +5720,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 {
|
|
|
@@ -5745,7 +5767,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);
|
|
|
@@ -5761,7 +5783,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);
|
|
|
@@ -9766,15 +9788,22 @@ get_external_image_format(Texture *tex) const {
|
|
|
|
|
|
case Texture::F_rgba:
|
|
|
case Texture::F_rgbm:
|
|
|
- case Texture::F_rgba4:
|
|
|
- case Texture::F_rgba5:
|
|
|
case Texture::F_rgba8:
|
|
|
case Texture::F_rgba12:
|
|
|
+ return _supports_bgr ? GL_BGRA : GL_RGBA;
|
|
|
+
|
|
|
+ case Texture::F_rgba4:
|
|
|
+ case Texture::F_rgba5:
|
|
|
case Texture::F_rgba16:
|
|
|
case Texture::F_rgba32:
|
|
|
case Texture::F_srgb_alpha:
|
|
|
case Texture::F_rgb10_a2:
|
|
|
+#ifdef OPENGLES
|
|
|
+ // OpenGL ES doesn't have sized BGRA formats.
|
|
|
+ return GL_RGBA;
|
|
|
+#else
|
|
|
return _supports_bgr ? GL_BGRA : GL_RGBA;
|
|
|
+#endif
|
|
|
|
|
|
case Texture::F_luminance:
|
|
|
#ifdef OPENGLES
|
|
|
@@ -10300,9 +10329,9 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
|
|
|
|
|
|
#ifdef OPENGLES
|
|
|
case Texture::F_rgba8:
|
|
|
- return GL_RGBA8_OES;
|
|
|
+ return _supports_bgr ? GL_BGRA : GL_RGBA8_OES;
|
|
|
case Texture::F_rgba12:
|
|
|
- return force_sized ? GL_RGBA8 : GL_RGBA;
|
|
|
+ return _supports_bgr ? GL_BGRA : (force_sized ? GL_RGBA8 : GL_RGBA);
|
|
|
#else
|
|
|
case Texture::F_rgba8:
|
|
|
if (Texture::is_unsigned(tex->get_component_type())) {
|
|
|
@@ -11419,31 +11448,43 @@ set_state_and_transform(const RenderState *target,
|
|
|
_state_pcollector.add_level(1);
|
|
|
PStatGPUTimer timer1(this, _draw_set_state_pcollector);
|
|
|
|
|
|
- if (transform != _internal_transform) {
|
|
|
+ bool transform_changed = transform != _internal_transform;
|
|
|
+ if (transform_changed) {
|
|
|
// PStatGPUTimer timer(this, _draw_set_state_transform_pcollector);
|
|
|
_transform_state_pcollector.add_level(1);
|
|
|
_internal_transform = transform;
|
|
|
do_issue_transform();
|
|
|
}
|
|
|
|
|
|
- //XXX the _inv_state_mask system does not appear to be used at the moment.
|
|
|
- //if (target == _state_rs && (_state_mask | _inv_state_mask).is_all_on()) {
|
|
|
- // return;
|
|
|
- //}
|
|
|
+ if (target == _state_rs && (_state_mask | _inv_state_mask).is_all_on()) {
|
|
|
+#ifndef OPENGLES_1
|
|
|
+ if (transform_changed) {
|
|
|
+ // The state has not changed, but the transform has. Set the new
|
|
|
+ // transform on the shader, if we have one.
|
|
|
+ if (_current_shader_context != nullptr) {
|
|
|
+ _current_shader_context->set_state_and_transform(_state_rs, transform,
|
|
|
+ _scene_setup->get_camera_transform(), _projection_mat);
|
|
|
+ }
|
|
|
+ }
|
|
|
+#endif
|
|
|
+ return;
|
|
|
+ }
|
|
|
_target_rs = 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();
|
|
|
_state_shader = _target_shader;
|
|
|
_state_mask.clear_bit(TextureAttrib::get_class_slot());
|
|
|
+ _state_mask.set_bit(ShaderAttrib::get_class_slot());
|
|
|
}
|
|
|
else if (!has_fixed_function_pipeline() && _current_shader == nullptr) { // In the case of OpenGL ES 2.x, we need to glUseShader before we draw anything.
|
|
|
do_issue_shader();
|
|
|
_state_mask.clear_bit(TextureAttrib::get_class_slot());
|
|
|
+ _state_mask.set_bit(ShaderAttrib::get_class_slot());
|
|
|
}
|
|
|
|
|
|
// Update all of the state that is bound to the shader program.
|
|
|
@@ -13780,7 +13821,11 @@ upload_simple_texture(CLP(TextureContext) *gtc) {
|
|
|
Texture *tex = gtc->get_texture();
|
|
|
nassertr(tex != nullptr, false);
|
|
|
|
|
|
+#ifdef OPENGLES
|
|
|
+ GLenum internal_format = GL_BGRA;
|
|
|
+#else
|
|
|
GLenum internal_format = GL_RGBA;
|
|
|
+#endif
|
|
|
GLenum external_format = GL_BGRA;
|
|
|
|
|
|
const unsigned char *image_ptr = tex->get_simple_ram_image();
|
|
|
@@ -13794,6 +13839,9 @@ upload_simple_texture(CLP(TextureContext) *gtc) {
|
|
|
// If the GL doesn't claim to support BGR, we may have to reverse the
|
|
|
// component ordering of the image.
|
|
|
external_format = GL_RGBA;
|
|
|
+#ifdef OPENGLES
|
|
|
+ internal_format = GL_RGBA;
|
|
|
+#endif
|
|
|
image_ptr = fix_component_ordering(bgr_image, image_ptr, image_size,
|
|
|
external_format, tex);
|
|
|
}
|