|
|
@@ -220,6 +220,7 @@ munge_format_impl(const GeomVertexFormat *orig,
|
|
|
// Combine the primary data columns into a single array.
|
|
|
new_format = new GeomVertexFormat(*format);
|
|
|
PT(GeomVertexArrayFormat) new_array_format = new GeomVertexArrayFormat;
|
|
|
+ size_t insert_at = 0;
|
|
|
|
|
|
const GeomVertexColumn *column = format->get_vertex_column();
|
|
|
if (column != nullptr) {
|
|
|
@@ -263,22 +264,34 @@ munge_format_impl(const GeomVertexFormat *orig,
|
|
|
// This is the first time we've encountered this texcoord name.
|
|
|
const GeomVertexColumn *texcoord_type = format->get_column(name);
|
|
|
|
|
|
+ // Note that we have to add something as a placeholder, even if the
|
|
|
+ // texture coordinates aren't defined.
|
|
|
+ int num_values = 2;
|
|
|
+ int column_alignment = 0;
|
|
|
+ int start = new_array_format->get_total_bytes();
|
|
|
+ start = (start + sizeof(PN_stdfloat) - 1) & ~(sizeof(PN_stdfloat) - 1);
|
|
|
if (texcoord_type != nullptr) {
|
|
|
- new_array_format->add_column
|
|
|
- (name, texcoord_type->get_num_values(), NT_stdfloat, C_texcoord,
|
|
|
- -1, texcoord_type->get_column_alignment());
|
|
|
- } else {
|
|
|
- // We have to add something as a placeholder, even if the
|
|
|
- // texture coordinates aren't defined.
|
|
|
- new_array_format->add_column(name, 2, NT_stdfloat, C_texcoord);
|
|
|
+ column_alignment = texcoord_type->get_column_alignment();
|
|
|
+ num_values = texcoord_type->get_num_values();
|
|
|
}
|
|
|
+ if (start + num_values * sizeof(PN_stdfloat) > glgsg->get_max_vertex_attrib_stride()) {
|
|
|
+ // We are exceeding the limit for stride reported by the driver.
|
|
|
+ // Start a new array.
|
|
|
+ new_format->insert_array(insert_at++, new_array_format);
|
|
|
+ new_array_format = new GeomVertexArrayFormat;
|
|
|
+ start = 0;
|
|
|
+ }
|
|
|
+ new_array_format->add_column(name, num_values, NT_stdfloat,
|
|
|
+ C_texcoord, start, column_alignment);
|
|
|
new_format->remove_column(name);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- new_format->insert_array(0, new_array_format);
|
|
|
+ if (new_array_format->get_num_columns() > 0) {
|
|
|
+ new_format->insert_array(insert_at, new_array_format);
|
|
|
+ }
|
|
|
format = GeomVertexFormat::register_format(new_format);
|
|
|
}
|
|
|
|
|
|
@@ -377,6 +390,7 @@ premunge_format_impl(const GeomVertexFormat *orig) {
|
|
|
// of doing this step at load time than you might be at run time.
|
|
|
new_format = new GeomVertexFormat(*format);
|
|
|
PT(GeomVertexArrayFormat) new_array_format = new GeomVertexArrayFormat;
|
|
|
+ size_t insert_at = 0;
|
|
|
|
|
|
const GeomVertexColumn *column = format->get_vertex_column();
|
|
|
if (column != nullptr) {
|
|
|
@@ -421,15 +435,25 @@ premunge_format_impl(const GeomVertexFormat *orig) {
|
|
|
// This is the first time we've encountered this texcoord name.
|
|
|
const GeomVertexColumn *texcoord_type = format->get_column(name);
|
|
|
|
|
|
+ // Note that we have to add something as a placeholder, even if the
|
|
|
+ // texture coordinates aren't defined.
|
|
|
+ int num_values = 2;
|
|
|
+ int column_alignment = 0;
|
|
|
+ int start = new_array_format->get_total_bytes();
|
|
|
+ start = (start + sizeof(PN_stdfloat) - 1) & ~(sizeof(PN_stdfloat) - 1);
|
|
|
if (texcoord_type != nullptr) {
|
|
|
- new_array_format->add_column
|
|
|
- (name, texcoord_type->get_num_values(), NT_stdfloat, C_texcoord,
|
|
|
- -1, texcoord_type->get_column_alignment());
|
|
|
- } else {
|
|
|
- // We have to add something as a placeholder, even if the
|
|
|
- // texture coordinates aren't defined.
|
|
|
- new_array_format->add_column(name, 2, NT_stdfloat, C_texcoord);
|
|
|
+ column_alignment = texcoord_type->get_column_alignment();
|
|
|
+ num_values = texcoord_type->get_num_values();
|
|
|
}
|
|
|
+ if (start + num_values * sizeof(PN_stdfloat) > 2048) {
|
|
|
+ // We are exceeding the limit for stride (and the one that is
|
|
|
+ // guaranteed to be supported). Start a new array.
|
|
|
+ new_format->insert_array(insert_at++, new_array_format);
|
|
|
+ new_array_format = new GeomVertexArrayFormat;
|
|
|
+ start = 0;
|
|
|
+ }
|
|
|
+ new_array_format->add_column(name, num_values, NT_stdfloat,
|
|
|
+ C_texcoord, start, column_alignment);
|
|
|
new_format->remove_column(name);
|
|
|
}
|
|
|
}
|
|
|
@@ -453,7 +477,9 @@ premunge_format_impl(const GeomVertexFormat *orig) {
|
|
|
}
|
|
|
|
|
|
// Finally, insert the interleaved array first in the format.
|
|
|
- new_format->insert_array(0, new_array_format);
|
|
|
+ if (new_array_format->get_num_columns() > 0) {
|
|
|
+ new_format->insert_array(insert_at, new_array_format);
|
|
|
+ }
|
|
|
format = GeomVertexFormat::register_format(new_format);
|
|
|
}
|
|
|
|