mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-15 22:54:00 +00:00
RasterizerGL: Ignore invalid/unset vertex attributes.
This should make the es2gears example not crash anymore.
This commit is contained in:
parent
403dfd68fc
commit
2dad1204e8
2 changed files with 11 additions and 1 deletions
|
@ -93,6 +93,7 @@ public:
|
||||||
|
|
||||||
struct VertexAttribute {
|
struct VertexAttribute {
|
||||||
enum class Size : u32 {
|
enum class Size : u32 {
|
||||||
|
Invalid = 0x0,
|
||||||
Size_32_32_32_32 = 0x01,
|
Size_32_32_32_32 = 0x01,
|
||||||
Size_32_32_32 = 0x02,
|
Size_32_32_32 = 0x02,
|
||||||
Size_16_16_16_16 = 0x03,
|
Size_16_16_16_16 = 0x03,
|
||||||
|
@ -257,6 +258,10 @@ public:
|
||||||
bool IsNormalized() const {
|
bool IsNormalized() const {
|
||||||
return (type == Type::SignedNorm) || (type == Type::UnsignedNorm);
|
return (type == Type::SignedNorm) || (type == Type::UnsignedNorm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsValid() const {
|
||||||
|
return size != Size::Invalid;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class PrimitiveTopology : u32 {
|
enum class PrimitiveTopology : u32 {
|
||||||
|
|
|
@ -161,11 +161,16 @@ std::pair<u8*, GLintptr> RasterizerOpenGL::SetupVertexArrays(u8* array_ptr,
|
||||||
// assume every shader uses them all.
|
// assume every shader uses them all.
|
||||||
for (unsigned index = 0; index < 16; ++index) {
|
for (unsigned index = 0; index < 16; ++index) {
|
||||||
auto& attrib = regs.vertex_attrib_format[index];
|
auto& attrib = regs.vertex_attrib_format[index];
|
||||||
|
|
||||||
|
// Ignore invalid attributes.
|
||||||
|
if (!attrib.IsValid())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
auto& buffer = regs.vertex_array[attrib.buffer];
|
||||||
LOG_TRACE(HW_GPU, "vertex attrib {}, count={}, size={}, type={}, offset={}, normalize={}",
|
LOG_TRACE(HW_GPU, "vertex attrib {}, count={}, size={}, type={}, offset={}, normalize={}",
|
||||||
index, attrib.ComponentCount(), attrib.SizeString(), attrib.TypeString(),
|
index, attrib.ComponentCount(), attrib.SizeString(), attrib.TypeString(),
|
||||||
attrib.offset.Value(), attrib.IsNormalized());
|
attrib.offset.Value(), attrib.IsNormalized());
|
||||||
|
|
||||||
auto& buffer = regs.vertex_array[attrib.buffer];
|
|
||||||
ASSERT(buffer.IsEnabled());
|
ASSERT(buffer.IsEnabled());
|
||||||
|
|
||||||
glEnableVertexAttribArray(index);
|
glEnableVertexAttribArray(index);
|
||||||
|
|
Loading…
Reference in a new issue