Skip to content

Commit

Permalink
remove deprecated usage
Browse files Browse the repository at this point in the history
  • Loading branch information
hana-alice committed Sep 21, 2023
1 parent 3d45769 commit 40a847c
Showing 1 changed file with 27 additions and 26 deletions.
53 changes: 27 additions & 26 deletions native/cocos/renderer/gfx-wgpu/WGPUCommandBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,32 +535,33 @@ void CCWGPUCommandBuffer::draw(const DrawInfo &info) {
bindStates();

auto *ia = static_cast<CCWGPUInputAssembler *>(_gpuCommandBufferObj->stateCache.inputAssembler);
if (ia->getIndirectBuffer()) {
auto *indirectBuffer = static_cast<CCWGPUBuffer *>(ia->getIndirectBuffer());
bool multiDrawIndirectSupport = false;

// indirectSupport not support, emscripten webgpu ver < 2021
// https://github.com/gpuweb/gpuweb/issues/1354
if (multiDrawIndirectSupport) {
// todo
} else {
if (info.indexCount) {
// indexedIndirect not supported, emsdk 2.0.26
uint32_t drawInfoCount = indirectBuffer->getCount();
for (size_t i = 0; i < drawInfoCount; i++) {
wgpuRenderPassEncoderDrawIndexedIndirect(_gpuCommandBufferObj->wgpuRenderPassEncoder,
indirectBuffer->gpuBufferObject()->wgpuBuffer,
indirectBuffer->getOffset() + i * sizeof(CCWGPUDrawIndexedIndirectObject));
}
} else {
uint32_t drawInfoCount = indirectBuffer->getCount();
for (size_t i = 0; i < drawInfoCount; i++) {
wgpuRenderPassEncoderDrawIndirect(_gpuCommandBufferObj->wgpuRenderPassEncoder,
indirectBuffer->gpuBufferObject()->wgpuBuffer,
indirectBuffer->getOffset() + i * sizeof(CCWGPUDrawIndirectObject));
}
}
}
// TODO(Zeqiang): implement indirect drawing
if (0) {
// auto *indirectBuffer = static_cast<CCWGPUBuffer *>(ia->getIndirectBuffer());
// bool multiDrawIndirectSupport = false;

// // indirectSupport not support, emscripten webgpu ver < 2021
// // https://github.com/gpuweb/gpuweb/issues/1354
// if (multiDrawIndirectSupport) {
// // todo
// } else {
// if (info.indexCount) {
// // indexedIndirect not supported, emsdk 2.0.26
// uint32_t drawInfoCount = indirectBuffer->getCount();
// for (size_t i = 0; i < drawInfoCount; i++) {
// wgpuRenderPassEncoderDrawIndexedIndirect(_gpuCommandBufferObj->wgpuRenderPassEncoder,
// indirectBuffer->gpuBufferObject()->wgpuBuffer,
// indirectBuffer->getOffset() + i * sizeof(CCWGPUDrawIndexedIndirectObject));
// }
// } else {
// uint32_t drawInfoCount = indirectBuffer->getCount();
// for (size_t i = 0; i < drawInfoCount; i++) {
// wgpuRenderPassEncoderDrawIndirect(_gpuCommandBufferObj->wgpuRenderPassEncoder,
// indirectBuffer->gpuBufferObject()->wgpuBuffer,
// indirectBuffer->getOffset() + i * sizeof(CCWGPUDrawIndirectObject));
// }
// }
// }
} else {
auto *indexBuffer = static_cast<CCWGPUBuffer *>(ia->getIndexBuffer());
bool drawIndexed = indexBuffer && info.indexCount;
Expand Down

0 comments on commit 40a847c

Please sign in to comment.