Created
November 18, 2019 01:54
-
-
Save Hurleyworks/0471f8f1bf47bfe0d3667b367804acb5 to your computer and use it in GitHub Desktop.
Optix7 mis-aligned address problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size_t byteOffset = 0; | |
// indices | |
indices.data = deviceBuffer + byteOffset; | |
indices.byte_stride = static_cast<uint16_t>(byteStride); | |
indices.count = static_cast<uint32_t>(tris.size()); | |
indices.elmt_byte_size = static_cast<uint16_t>(sizeof(uint32_t)); | |
uintptr_t number = (uintptr_t)indices.data; | |
LOG(DBUG) << "Indices start: " << number << "::" << number % sizeof(uint32_t); | |
byteOffset += tris.size() * sizeof(uint32_t); | |
// vertices | |
positions.data = deviceBuffer + byteOffset; | |
positions.byte_stride = static_cast<uint16_t>(byteStride); | |
positions.count = static_cast<uint32_t>(mesh->V.cols()); | |
positions.elmt_byte_size = static_cast<uint16_t>(sizeof(float)); | |
number = (uintptr_t)positions.data; | |
LOG(DBUG) << "Positions start: " << number << "::" << number % sizeof(float); | |
byteOffset += mesh->V.size() * sizeof(float); | |
// normals | |
normals.data = deviceBuffer + byteOffset; | |
normals.byte_stride = static_cast<uint16_t>(byteStride); | |
normals.count = static_cast<uint32_t>(mesh->N.cols()); | |
normals.elmt_byte_size = static_cast<uint16_t>(sizeof(float)); | |
number = (uintptr_t)normals.data; | |
LOG(DBUG) << "Normals start: " << number << "::" << number % sizeof(float); | |
byteOffset += mesh->N.size() * sizeof(float); | |
// textcoord0 | |
auto it = mesh->vmaps.find("UV"); | |
if (it != mesh->vmaps.end()) | |
{ | |
VertexMapRef vmap = it->second; | |
texcoords.data = deviceBuffer + byteOffset; | |
texcoords.byte_stride = static_cast<uint16_t>(byteStride); | |
texcoords.count = static_cast<uint32_t>(vmap->values.cols()); | |
texcoords.elmt_byte_size = static_cast<uint16_t>(sizeof(float)); | |
number = (uintptr_t)texcoords.data; | |
LOG(DBUG) << "UV start: " << number << "::" << number % sizeof(float); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment