mirror of
https://github.com/encounter/aurora.git
synced 2026-07-09 18:19:33 -07:00
Disable texture upload buffer
This commit is contained in:
+23
-19
@@ -30,8 +30,8 @@ std::vector<std::string> g_debugGroupStack;
|
||||
std::vector<std::string> g_debugMarkers;
|
||||
#endif
|
||||
|
||||
constexpr uint64_t StagingBufferSize =
|
||||
UniformBufferSize + VertexBufferSize + IndexBufferSize + StorageBufferSize + TextureUploadSize;
|
||||
constexpr uint64_t StagingBufferSize = UniformBufferSize + VertexBufferSize + IndexBufferSize + StorageBufferSize +
|
||||
(UseTextureBuffer ? TextureUploadSize : 0);
|
||||
|
||||
struct ShaderDrawCommand {
|
||||
ShaderType type;
|
||||
@@ -528,7 +528,9 @@ void begin_frame() {
|
||||
mapBuffer(g_uniforms, UniformBufferSize);
|
||||
mapBuffer(g_indices, IndexBufferSize);
|
||||
mapBuffer(g_storage, StorageBufferSize);
|
||||
mapBuffer(g_textureUpload, TextureUploadSize);
|
||||
if constexpr (UseTextureBuffer) {
|
||||
mapBuffer(g_textureUpload, TextureUploadSize);
|
||||
}
|
||||
|
||||
g_stats.drawCallCount = 0;
|
||||
g_stats.mergedDrawCallCount = 0;
|
||||
@@ -562,23 +564,25 @@ void end_frame(const wgpu::CommandEncoder& cmd) {
|
||||
g_stats.lastUniformSize = writeBuffer(g_uniforms, g_uniformBuffer, UniformBufferSize, "Uniform");
|
||||
g_stats.lastIndexSize = writeBuffer(g_indices, g_indexBuffer, IndexBufferSize, "Index");
|
||||
g_stats.lastStorageSize = writeBuffer(g_storage, g_storageBuffer, StorageBufferSize, "Storage");
|
||||
g_stats.lastTextureUploadSize = g_textureUpload.size();
|
||||
{
|
||||
// Perform texture copies
|
||||
for (const auto& item : g_textureUploads) {
|
||||
const wgpu::TexelCopyBufferInfo buf{
|
||||
.layout =
|
||||
wgpu::TexelCopyBufferLayout{
|
||||
.offset = item.layout.offset + bufferOffset,
|
||||
.bytesPerRow = AURORA_ALIGN(item.layout.bytesPerRow, 256),
|
||||
.rowsPerImage = item.layout.rowsPerImage,
|
||||
},
|
||||
.buffer = g_stagingBuffers[currentStagingBuffer],
|
||||
};
|
||||
cmd.CopyBufferToTexture(&buf, &item.tex, &item.size);
|
||||
if constexpr (UseTextureBuffer) {
|
||||
g_stats.lastTextureUploadSize = g_textureUpload.size();
|
||||
{
|
||||
// Perform texture copies
|
||||
for (const auto& item : g_textureUploads) {
|
||||
const wgpu::TexelCopyBufferInfo buf{
|
||||
.layout =
|
||||
wgpu::TexelCopyBufferLayout{
|
||||
.offset = item.layout.offset + bufferOffset,
|
||||
.bytesPerRow = AURORA_ALIGN(item.layout.bytesPerRow, 256),
|
||||
.rowsPerImage = item.layout.rowsPerImage,
|
||||
},
|
||||
.buffer = g_stagingBuffers[currentStagingBuffer],
|
||||
};
|
||||
cmd.CopyBufferToTexture(&buf, &item.tex, &item.size);
|
||||
}
|
||||
g_textureUploads.clear();
|
||||
g_textureUpload.release();
|
||||
}
|
||||
g_textureUploads.clear();
|
||||
g_textureUpload.release();
|
||||
}
|
||||
currentStagingBuffer = (currentStagingBuffer + 1) % g_stagingBuffers.size();
|
||||
map_staging_buffer();
|
||||
|
||||
@@ -162,6 +162,7 @@ private:
|
||||
} // namespace aurora
|
||||
|
||||
namespace aurora::gfx {
|
||||
inline constexpr bool UseTextureBuffer = false;
|
||||
inline constexpr uint64_t UniformBufferSize = 25165824; // 24mb
|
||||
inline constexpr uint64_t VertexBufferSize = 3145728; // 3mb
|
||||
inline constexpr uint64_t IndexBufferSize = 1048576; // 1mb
|
||||
|
||||
+30
-14
@@ -98,13 +98,21 @@ TextureHandle new_static_texture_2d(uint32_t width, uint32_t height, uint32_t mi
|
||||
.texture = ref.texture,
|
||||
.mipLevel = mip,
|
||||
};
|
||||
const auto range = push_texture_data(data.data() + offset, dataSize, bytesPerRow, heightBlocks);
|
||||
const wgpu::TexelCopyBufferLayout dataLayout{
|
||||
.offset = range.offset,
|
||||
.bytesPerRow = bytesPerRow,
|
||||
.rowsPerImage = heightBlocks,
|
||||
};
|
||||
g_textureUploads.emplace_back(dataLayout, std::move(dstView), physicalSize);
|
||||
if constexpr (UseTextureBuffer) {
|
||||
const auto range = push_texture_data(data.data() + offset, dataSize, bytesPerRow, heightBlocks);
|
||||
const wgpu::TexelCopyBufferLayout dataLayout{
|
||||
.offset = range.offset,
|
||||
.bytesPerRow = bytesPerRow,
|
||||
.rowsPerImage = heightBlocks,
|
||||
};
|
||||
g_textureUploads.emplace_back(dataLayout, std::move(dstView), physicalSize);
|
||||
} else {
|
||||
const wgpu::TexelCopyBufferLayout dataLayout{
|
||||
.bytesPerRow = bytesPerRow,
|
||||
.rowsPerImage = heightBlocks,
|
||||
};
|
||||
g_queue.WriteTexture(&dstView, data.data() + offset, dataSize, &dataLayout, &physicalSize);
|
||||
}
|
||||
offset += dataSize;
|
||||
}
|
||||
if (data.size() != UINT32_MAX && offset < data.size()) {
|
||||
@@ -286,13 +294,21 @@ void write_texture(const TextureRef& ref, ArrayRef<uint8_t> data) noexcept {
|
||||
.texture = ref.texture,
|
||||
.mipLevel = mip,
|
||||
};
|
||||
const auto range = push_texture_data(data.data() + offset, dataSize, bytesPerRow, heightBlocks);
|
||||
const wgpu::TexelCopyBufferLayout dataLayout{
|
||||
.offset = range.offset,
|
||||
.bytesPerRow = bytesPerRow,
|
||||
.rowsPerImage = heightBlocks,
|
||||
};
|
||||
g_textureUploads.emplace_back(dataLayout, std::move(dstView), physicalSize);
|
||||
if constexpr (UseTextureBuffer) {
|
||||
const auto range = push_texture_data(data.data() + offset, dataSize, bytesPerRow, heightBlocks);
|
||||
const wgpu::TexelCopyBufferLayout dataLayout{
|
||||
.offset = range.offset,
|
||||
.bytesPerRow = bytesPerRow,
|
||||
.rowsPerImage = heightBlocks,
|
||||
};
|
||||
g_textureUploads.emplace_back(dataLayout, std::move(dstView), physicalSize);
|
||||
} else {
|
||||
const wgpu::TexelCopyBufferLayout dataLayout{
|
||||
.bytesPerRow = bytesPerRow,
|
||||
.rowsPerImage = heightBlocks,
|
||||
};
|
||||
g_queue.WriteTexture(&dstView, data.data() + offset, dataSize, &dataLayout, &physicalSize);
|
||||
}
|
||||
offset += dataSize;
|
||||
}
|
||||
if (data.size() != UINT32_MAX && offset < data.size()) {
|
||||
|
||||
Reference in New Issue
Block a user