mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-08 07:05:40 +12:00
HW shaders: Fix attribute fetch
This commit is contained in:
parent
e332ab2e58
commit
15b6a9e2d9
2 changed files with 6 additions and 5 deletions
|
@ -64,7 +64,6 @@ void GPU::getAcceleratedDrawInfo(PICA::DrawAcceleration& accel, bool indexed) {
|
||||||
if (!fixedAttrib) {
|
if (!fixedAttrib) {
|
||||||
auto& attrData = attributeInfo[buffer]; // Get information for this attribute
|
auto& attrData = attributeInfo[buffer]; // Get information for this attribute
|
||||||
u64 attrCfg = attrData.getConfigFull(); // Get config1 | (config2 << 32)
|
u64 attrCfg = attrData.getConfigFull(); // Get config1 | (config2 << 32)
|
||||||
u32 attributeOffset = attrData.offset;
|
|
||||||
|
|
||||||
if (attrData.componentCount != 0) {
|
if (attrData.componentCount != 0) {
|
||||||
// Size of the attribute in bytes multiplied by the total number of vertices
|
// Size of the attribute in bytes multiplied by the total number of vertices
|
||||||
|
@ -73,6 +72,7 @@ void GPU::getAcceleratedDrawInfo(PICA::DrawAcceleration& accel, bool indexed) {
|
||||||
accel.vertexDataSize += (bytes + 3) & ~3;
|
accel.vertexDataSize += (bytes + 3) & ~3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 attributeOffset = 0;
|
||||||
for (int i = 0; i < attrData.componentCount; i++) {
|
for (int i = 0; i < attrData.componentCount; i++) {
|
||||||
uint index = (attrCfg >> (i * 4)) & 0xf; // Get index of attribute in vertexCfg
|
uint index = (attrCfg >> (i * 4)) & 0xf; // Get index of attribute in vertexCfg
|
||||||
auto& attr = accel.attributeInfo[attrCount];
|
auto& attr = accel.attributeInfo[attrCount];
|
||||||
|
@ -101,6 +101,10 @@ void GPU::getAcceleratedDrawInfo(PICA::DrawAcceleration& accel, bool indexed) {
|
||||||
// Mark the attribute as enabled
|
// Mark the attribute as enabled
|
||||||
accel.enabledAttributeMask |= 1 << inputReg;
|
accel.enabledAttributeMask |= 1 << inputReg;
|
||||||
|
|
||||||
|
// Get a pointer to the data where this attribute is stored
|
||||||
|
const u32 attrAddress = vertexBase + attributeOffset + attrData.offset + (accel.minimumIndex * attrData.size);
|
||||||
|
|
||||||
|
attr.data = getPointerPhys<u8>(attrAddress);
|
||||||
attr.inputReg = inputReg;
|
attr.inputReg = inputReg;
|
||||||
attr.componentCount = size;
|
attr.componentCount = size;
|
||||||
attr.offset = attributeOffset;
|
attr.offset = attributeOffset;
|
||||||
|
@ -110,9 +114,6 @@ void GPU::getAcceleratedDrawInfo(PICA::DrawAcceleration& accel, bool indexed) {
|
||||||
attr.isPadding = false;
|
attr.isPadding = false;
|
||||||
attributeOffset += attr.size;
|
attributeOffset += attr.size;
|
||||||
|
|
||||||
// Get a pointer to the data where this attribute is stored
|
|
||||||
const u32 attrAddress = vertexBase + attr.offset + (accel.minimumIndex * attrData.size);
|
|
||||||
attr.data = getPointerPhys<u8>(attrAddress);
|
|
||||||
attrCount += 1;
|
attrCount += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -512,7 +512,7 @@ void RendererGL::drawVertices(PICA::PrimType primType, std::span<const Vertex> v
|
||||||
hwIndexBuffer->Bind();
|
hwIndexBuffer->Bind();
|
||||||
glDrawRangeElementsBaseVertex(
|
glDrawRangeElementsBaseVertex(
|
||||||
primitiveTopology, minimumIndex, maximumIndex, GLsizei(vertices.size()), usingShortIndices ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE,
|
primitiveTopology, minimumIndex, maximumIndex, GLsizei(vertices.size()), usingShortIndices ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE,
|
||||||
hwIndexBufferOffset, -minimumIndex
|
hwIndexBufferOffset, -GLint(minimumIndex)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// When doing non-indexed rendering, just use glDrawArrays
|
// When doing non-indexed rendering, just use glDrawArrays
|
||||||
|
|
Loading…
Add table
Reference in a new issue