mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-08-15 14:43:32 -07:00
Reduces vertex maximum stride to 16
https://wikis.khronos.org/opengl/Vertex_Specification_Best_Practices > The alignment of any attribute's data should be no less than 4 bytes. But to make it a bit safer for older drivers we prefer to use 16 bytes alignment (vec4) for now to match std140.
This commit is contained in:
parent
db8c05572f
commit
abf444d91c
3 changed files with 4 additions and 7 deletions
|
|
@ -26,7 +26,6 @@ struct Vertex
|
|||
vec4 tangent;
|
||||
vec4 normal;
|
||||
vec4 position;
|
||||
vec4 padding;
|
||||
};
|
||||
|
||||
STORAGE_BUFFER(0) restrict readonly buffer InputVertices
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ namespace
|
|||
//
|
||||
// Created on a model load and read by a compute shader for each frame where
|
||||
// the model is visible.
|
||||
// InputVertex(size/stride=64):
|
||||
// InputVertex(size/stride=48):
|
||||
// vec4/CVector4D tangent (offset=0)
|
||||
// vec3/CVector3D normal (offset=16)
|
||||
// vec3/CVector3D position (offset=32)
|
||||
|
|
@ -251,7 +251,7 @@ ModelDefRData::ModelDefRData(const CModelDefPtr& modelDef)
|
|||
m_UVArray.FreeBackingStore();
|
||||
}
|
||||
|
||||
ENSURE(m_Array.GetStride() == INPUT_VERTEX_ATTRIBUTE_ALIGNMENT * 4);
|
||||
ENSURE(m_Array.GetStride() == INPUT_VERTEX_ATTRIBUTE_ALIGNMENT * 3);
|
||||
ENSURE(m_Position.offset == INPUT_VERTEX_POSITION_OFFSET);
|
||||
ENSURE(m_Normal.offset == INPUT_VERTEX_NORMAL_OFFSET);
|
||||
ENSURE(m_Tangent.offset == INPUT_VERTEX_TANGENT_OFFSET);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2025 Wildfire Games.
|
||||
/* Copyright (C) 2026 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
|
|
@ -231,10 +231,8 @@ static uint32_t RoundStride(uint32_t stride)
|
|||
return 4;
|
||||
if (stride <= 8)
|
||||
return 8;
|
||||
if (stride <= 16)
|
||||
return 16;
|
||||
|
||||
return Align<32>(stride);
|
||||
return Align<16>(stride);
|
||||
}
|
||||
|
||||
// Re-layout by assigning offsets on a first-come first-serve basis,
|
||||
|
|
|
|||
Loading…
Reference in a new issue