mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-06 19:42:39 +08:00
[ci skip][AUTO]: Automated clang-format update: 3b49861e5f (#10261) (#10267)
Co-authored-by: cocos-robot <cocos-robot@cocos.com>
This commit is contained in:
@@ -45,18 +45,18 @@ using namespace emscripten;
|
||||
CCWGPUDescriptorSet::CCWGPUDescriptorSet() : wrapper<DescriptorSet>(val::object()) {
|
||||
}
|
||||
|
||||
void CCWGPUDescriptorSet::doInit(const DescriptorSetInfo& info) {
|
||||
void CCWGPUDescriptorSet::doInit(const DescriptorSetInfo &info) {
|
||||
_gpuBindGroupObj = CC_NEW(CCWGPUBindGroupObject);
|
||||
|
||||
auto* dsLayout = static_cast<CCWGPUDescriptorSetLayout*>(_layout);
|
||||
CCWGPUBindGroupLayoutObject* layoutEntries = dsLayout->gpuLayoutEntryObject();
|
||||
const auto& bindings = dsLayout->getBindings();
|
||||
CCWGPUDeviceObject* deviceObj = CCWGPUDevice::getInstance()->gpuDeviceObject();
|
||||
auto * dsLayout = static_cast<CCWGPUDescriptorSetLayout *>(_layout);
|
||||
CCWGPUBindGroupLayoutObject *layoutEntries = dsLayout->gpuLayoutEntryObject();
|
||||
const auto & bindings = dsLayout->getBindings();
|
||||
CCWGPUDeviceObject * deviceObj = CCWGPUDevice::getInstance()->gpuDeviceObject();
|
||||
for (size_t i = 0; i < bindings.size(); i++) {
|
||||
// effect.ts: INPUT_ATTACHMENT as combined texture but no sampler_texture desc type.
|
||||
if (hasFlag(COMBINED_ST_IN_USE, bindings[i].descriptorType)) {
|
||||
//1. texture
|
||||
CCWGPUTexture* texture = deviceObj->defaultResources.commonTexture;
|
||||
CCWGPUTexture * texture = deviceObj->defaultResources.commonTexture;
|
||||
WGPUBindGroupEntry texEntry = {
|
||||
.binding = bindings[i].binding,
|
||||
.textureView = texture->gpuTextureObject()->selfView,
|
||||
@@ -66,7 +66,7 @@ void CCWGPUDescriptorSet::doInit(const DescriptorSetInfo& info) {
|
||||
dsLayout->updateLayout(texEntry.binding, nullptr, texture);
|
||||
|
||||
// 2. sampler
|
||||
CCWGPUSampler* sampler = deviceObj->defaultResources.sampler;
|
||||
CCWGPUSampler * sampler = deviceObj->defaultResources.sampler;
|
||||
WGPUBindGroupEntry smpEntry = {
|
||||
.binding = bindings[i].binding + CC_WGPU_MAX_ATTACHMENTS,
|
||||
.sampler = sampler->gpuSampler(),
|
||||
@@ -75,7 +75,7 @@ void CCWGPUDescriptorSet::doInit(const DescriptorSetInfo& info) {
|
||||
_samplerIdxMap.insert(std::make_pair<uint8_t, uint8_t>(bindings[i].binding, _gpuBindGroupObj->bindGroupEntries.size() - 1));
|
||||
dsLayout->updateLayout(smpEntry.binding, nullptr, nullptr, sampler);
|
||||
} else if (hasFlag(DESCRIPTOR_BUFFER_TYPE, bindings[i].descriptorType)) {
|
||||
CCWGPUBuffer* buffer = hasFlag(DescriptorType::DYNAMIC_STORAGE_BUFFER | DescriptorType::STORAGE_BUFFER, bindings[i].descriptorType)
|
||||
CCWGPUBuffer * buffer = hasFlag(DescriptorType::DYNAMIC_STORAGE_BUFFER | DescriptorType::STORAGE_BUFFER, bindings[i].descriptorType)
|
||||
? deviceObj->defaultResources.storageBuffer
|
||||
: deviceObj->defaultResources.uniformBuffer;
|
||||
WGPUBindGroupEntry bufferEntry = {
|
||||
@@ -90,7 +90,7 @@ void CCWGPUDescriptorSet::doInit(const DescriptorSetInfo& info) {
|
||||
}
|
||||
_gpuBindGroupObj->bindGroupEntries.push_back(bufferEntry);
|
||||
} else if (bindings[i].descriptorType == DescriptorType::STORAGE_IMAGE) {
|
||||
CCWGPUTexture* texture = deviceObj->defaultResources.storageTexture;
|
||||
CCWGPUTexture * texture = deviceObj->defaultResources.storageTexture;
|
||||
WGPUBindGroupEntry texEntry = {
|
||||
.binding = bindings[i].binding,
|
||||
.textureView = texture->gpuTextureObject()->selfView,
|
||||
@@ -116,16 +116,16 @@ void CCWGPUDescriptorSet::update() {
|
||||
if (!_isDirty) {
|
||||
return;
|
||||
}
|
||||
auto* dsLayout = static_cast<CCWGPUDescriptorSetLayout*>(_layout);
|
||||
const auto& bindings = dsLayout->getBindings();
|
||||
auto * dsLayout = static_cast<CCWGPUDescriptorSetLayout *>(_layout);
|
||||
const auto &bindings = dsLayout->getBindings();
|
||||
|
||||
for (size_t i = 0; i < bindings.size(); i++) {
|
||||
const auto& binding = bindings[i];
|
||||
const auto &binding = bindings[i];
|
||||
uint8_t resourceIndex = _layout->getDescriptorIndices()[i];
|
||||
if (hasFlag(DESCRIPTOR_BUFFER_TYPE, bindings[i].descriptorType)) {
|
||||
if (_buffers[resourceIndex]) {
|
||||
auto* buffer = static_cast<CCWGPUBuffer*>(_buffers[resourceIndex]);
|
||||
auto& bindGroupEntry = _gpuBindGroupObj->bindGroupEntries[i];
|
||||
auto *buffer = static_cast<CCWGPUBuffer *>(_buffers[resourceIndex]);
|
||||
auto &bindGroupEntry = _gpuBindGroupObj->bindGroupEntries[i];
|
||||
buffer->check();
|
||||
bindGroupEntry.binding = binding.binding;
|
||||
bindGroupEntry.buffer = buffer->gpuBufferObject()->wgpuBuffer;
|
||||
@@ -148,16 +148,16 @@ void CCWGPUDescriptorSet::update() {
|
||||
uint8_t textureIdx = texIter != _textureIdxMap.end() ? texIter->second : 255;
|
||||
uint8_t samplerIdx = smpIter != _samplerIdxMap.end() ? smpIter->second : 255;
|
||||
if (textureIdx != 255 && _textures[resourceIndex]) {
|
||||
auto& bindGroupEntry = _gpuBindGroupObj->bindGroupEntries[textureIdx];
|
||||
auto* texture = static_cast<CCWGPUTexture*>(_textures[resourceIndex]);
|
||||
auto &bindGroupEntry = _gpuBindGroupObj->bindGroupEntries[textureIdx];
|
||||
auto *texture = static_cast<CCWGPUTexture *>(_textures[resourceIndex]);
|
||||
bindGroupEntry.binding = binding.binding;
|
||||
bindGroupEntry.textureView = texture->gpuTextureObject()->selfView;
|
||||
dsLayout->updateLayout(bindGroupEntry.binding, nullptr, texture);
|
||||
_gpuBindGroupObj->bindingSet.insert(binding.binding);
|
||||
}
|
||||
if (samplerIdx != 255 && _samplers[resourceIndex]) {
|
||||
auto& bindGroupEntry = _gpuBindGroupObj->bindGroupEntries[samplerIdx];
|
||||
auto* sampler = static_cast<CCWGPUSampler*>(_samplers[resourceIndex]);
|
||||
auto &bindGroupEntry = _gpuBindGroupObj->bindGroupEntries[samplerIdx];
|
||||
auto *sampler = static_cast<CCWGPUSampler *>(_samplers[resourceIndex]);
|
||||
bindGroupEntry.binding = binding.binding + CC_WGPU_MAX_ATTACHMENTS;
|
||||
bindGroupEntry.sampler = sampler->gpuSampler();
|
||||
dsLayout->updateLayout(bindGroupEntry.binding, nullptr, nullptr, sampler);
|
||||
@@ -165,8 +165,8 @@ void CCWGPUDescriptorSet::update() {
|
||||
}
|
||||
} else if (DescriptorType::STORAGE_IMAGE == bindings[i].descriptorType) {
|
||||
if (_textures[resourceIndex]) {
|
||||
auto& bindGroupEntry = _gpuBindGroupObj->bindGroupEntries[resourceIndex];
|
||||
auto* texture = static_cast<CCWGPUTexture*>(_textures[resourceIndex]);
|
||||
auto &bindGroupEntry = _gpuBindGroupObj->bindGroupEntries[resourceIndex];
|
||||
auto *texture = static_cast<CCWGPUTexture *>(_textures[resourceIndex]);
|
||||
bindGroupEntry.binding = binding.binding;
|
||||
bindGroupEntry.textureView = texture->gpuTextureObject()->selfView;
|
||||
dsLayout->updateLayout(bindGroupEntry.binding, nullptr, texture);
|
||||
@@ -176,11 +176,11 @@ void CCWGPUDescriptorSet::update() {
|
||||
}
|
||||
|
||||
void CCWGPUDescriptorSet::prepare() {
|
||||
auto buffIter = std::find_if(_buffers.begin(), _buffers.end(), [](const Buffer* buffer) {
|
||||
return buffer ? static_cast<const CCWGPUBuffer*>(buffer)->internalChanged() : false;
|
||||
auto buffIter = std::find_if(_buffers.begin(), _buffers.end(), [](const Buffer *buffer) {
|
||||
return buffer ? static_cast<const CCWGPUBuffer *>(buffer)->internalChanged() : false;
|
||||
});
|
||||
auto texIter = std::find_if(_textures.begin(), _textures.end(), [](const Texture* texture) {
|
||||
return texture ? static_cast<const CCWGPUTexture*>(texture)->internalChanged() : false;
|
||||
auto texIter = std::find_if(_textures.begin(), _textures.end(), [](const Texture *texture) {
|
||||
return texture ? static_cast<const CCWGPUTexture *>(texture)->internalChanged() : false;
|
||||
});
|
||||
|
||||
bool forceUpdate = buffIter != _buffers.end() || texIter != _textures.end();
|
||||
@@ -190,7 +190,7 @@ void CCWGPUDescriptorSet::prepare() {
|
||||
}
|
||||
|
||||
if (_isDirty || forceUpdate || !_gpuBindGroupObj->bindgroup) {
|
||||
auto* dsLayout = static_cast<CCWGPUDescriptorSetLayout*>(_layout);
|
||||
auto *dsLayout = static_cast<CCWGPUDescriptorSetLayout *>(_layout);
|
||||
dsLayout->prepare(forceUpdate);
|
||||
// std::vector<WGPUBindGroupEntry>
|
||||
// bindGroupEntries;
|
||||
@@ -201,7 +201,7 @@ void CCWGPUDescriptorSet::prepare() {
|
||||
// }),
|
||||
// bindGroupEntries.end());
|
||||
|
||||
const auto& entries = _gpuBindGroupObj->bindGroupEntries;
|
||||
const auto &entries = _gpuBindGroupObj->bindGroupEntries;
|
||||
|
||||
// for (size_t j = 0; j < entries.size(); j++) {
|
||||
// const auto& entry = entries[j];
|
||||
@@ -210,7 +210,7 @@ void CCWGPUDescriptorSet::prepare() {
|
||||
// }
|
||||
// }
|
||||
|
||||
CCWGPUDeviceObject* deviceObj = CCWGPUDevice::getInstance()->gpuDeviceObject();
|
||||
CCWGPUDeviceObject *deviceObj = CCWGPUDevice::getInstance()->gpuDeviceObject();
|
||||
if (_gpuBindGroupObj->bindgroup && _gpuBindGroupObj->bindgroup != anoymous::defaultBindGroup) {
|
||||
wgpuBindGroupRelease(_gpuBindGroupObj->bindgroup);
|
||||
}
|
||||
@@ -232,14 +232,14 @@ void CCWGPUDescriptorSet::prepare() {
|
||||
}
|
||||
_isDirty = false;
|
||||
if (buffIter != _buffers.end())
|
||||
std::for_each(_buffers.begin(), _buffers.end(), [](Buffer* buffer) {
|
||||
std::for_each(_buffers.begin(), _buffers.end(), [](Buffer *buffer) {
|
||||
if (buffer)
|
||||
static_cast<CCWGPUBuffer*>(buffer)->stamp();
|
||||
static_cast<CCWGPUBuffer *>(buffer)->stamp();
|
||||
});
|
||||
if (texIter != _textures.end())
|
||||
std::for_each(_textures.begin(), _textures.end(), [](Texture* texture) {
|
||||
std::for_each(_textures.begin(), _textures.end(), [](Texture *texture) {
|
||||
if (texture)
|
||||
static_cast<CCWGPUTexture*>(texture)->stamp();
|
||||
static_cast<CCWGPUTexture *>(texture)->stamp();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -248,11 +248,11 @@ uint8_t CCWGPUDescriptorSet::dynamicOffsetCount() const {
|
||||
return _dynamicOffsets.size();
|
||||
}
|
||||
|
||||
void* CCWGPUDescriptorSet::defaultBindGroup() {
|
||||
CCWGPUDeviceObject* deviceObj = CCWGPUDevice::getInstance()->gpuDeviceObject();
|
||||
void *CCWGPUDescriptorSet::defaultBindGroup() {
|
||||
CCWGPUDeviceObject *deviceObj = CCWGPUDevice::getInstance()->gpuDeviceObject();
|
||||
|
||||
if (!anoymous::defaultBindGroup) {
|
||||
CCWGPUBuffer* buffer = deviceObj->defaultResources.uniformBuffer;
|
||||
CCWGPUBuffer * buffer = deviceObj->defaultResources.uniformBuffer;
|
||||
WGPUBindGroupEntry bufferEntry = {
|
||||
.binding = 0,
|
||||
.buffer = buffer->gpuBufferObject()->wgpuBuffer,
|
||||
|
||||
Reference in New Issue
Block a user