mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-03 01:12:42 +08:00
Remove some format rule (#10919)
* remove some rules * format all codes with new format rule
This commit is contained in:
@@ -48,17 +48,17 @@ CCWGPUDescriptorSet::CCWGPUDescriptorSet() : wrapper<DescriptorSet>(val::object(
|
||||
void CCWGPUDescriptorSet::doInit(const DescriptorSetInfo &info) {
|
||||
_gpuBindGroupObj = ccnew CCWGPUBindGroupObject;
|
||||
|
||||
auto * dsLayout = static_cast<CCWGPUDescriptorSetLayout *>(_layout);
|
||||
auto *dsLayout = static_cast<CCWGPUDescriptorSetLayout *>(_layout);
|
||||
CCWGPUBindGroupLayoutObject *layoutEntries = dsLayout->gpuLayoutEntryObject();
|
||||
const auto & bindings = dsLayout->getBindings();
|
||||
CCWGPUDeviceObject * deviceObj = CCWGPUDevice::getInstance()->gpuDeviceObject();
|
||||
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,
|
||||
.binding = bindings[i].binding,
|
||||
.textureView = texture->gpuTextureObject()->selfView,
|
||||
};
|
||||
_gpuBindGroupObj->bindGroupEntries.push_back(texEntry);
|
||||
@@ -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,14 +75,14 @@ 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)
|
||||
? deviceObj->defaultResources.storageBuffer
|
||||
: deviceObj->defaultResources.uniformBuffer;
|
||||
CCWGPUBuffer *buffer = hasFlag(DescriptorType::DYNAMIC_STORAGE_BUFFER | DescriptorType::STORAGE_BUFFER, bindings[i].descriptorType)
|
||||
? deviceObj->defaultResources.storageBuffer
|
||||
: deviceObj->defaultResources.uniformBuffer;
|
||||
WGPUBindGroupEntry bufferEntry = {
|
||||
.binding = bindings[i].binding,
|
||||
.buffer = buffer->gpuBufferObject()->wgpuBuffer,
|
||||
.size = buffer->getSize(),
|
||||
.offset = buffer->getOffset(),
|
||||
.buffer = buffer->gpuBufferObject()->wgpuBuffer,
|
||||
.size = buffer->getSize(),
|
||||
.offset = buffer->getOffset(),
|
||||
};
|
||||
|
||||
if (hasAnyFlags(bindings[i].descriptorType, DescriptorType::DYNAMIC_STORAGE_BUFFER | DescriptorType::DYNAMIC_UNIFORM_BUFFER)) {
|
||||
@@ -90,9 +90,9 @@ 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,
|
||||
.binding = bindings[i].binding,
|
||||
.textureView = texture->gpuTextureObject()->selfView,
|
||||
};
|
||||
_gpuBindGroupObj->bindGroupEntries.push_back(texEntry);
|
||||
@@ -116,21 +116,21 @@ void CCWGPUDescriptorSet::update() {
|
||||
if (!_isDirty) {
|
||||
return;
|
||||
}
|
||||
auto * dsLayout = static_cast<CCWGPUDescriptorSetLayout *>(_layout);
|
||||
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];
|
||||
uint8_t resourceIndex = _layout->getDescriptorIndices()[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 *buffer = static_cast<CCWGPUBuffer *>(_buffers[resourceIndex]);
|
||||
auto &bindGroupEntry = _gpuBindGroupObj->bindGroupEntries[i];
|
||||
buffer->check();
|
||||
bindGroupEntry.binding = binding.binding;
|
||||
bindGroupEntry.buffer = buffer->gpuBufferObject()->wgpuBuffer;
|
||||
bindGroupEntry.offset = buffer->getOffset();
|
||||
bindGroupEntry.size = buffer->getSize();
|
||||
bindGroupEntry.buffer = buffer->gpuBufferObject()->wgpuBuffer;
|
||||
bindGroupEntry.offset = buffer->getOffset();
|
||||
bindGroupEntry.size = buffer->getSize();
|
||||
dsLayout->updateLayout(bindGroupEntry.binding, buffer);
|
||||
uint8_t bindIndex = binding.binding;
|
||||
if (hasAnyFlags(binding.descriptorType, DescriptorType::DYNAMIC_STORAGE_BUFFER | DescriptorType::DYNAMIC_UNIFORM_BUFFER)) {
|
||||
@@ -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]);
|
||||
bindGroupEntry.binding = binding.binding;
|
||||
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,9 +165,9 @@ 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]);
|
||||
bindGroupEntry.binding = binding.binding;
|
||||
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);
|
||||
}
|
||||
@@ -179,7 +179,7 @@ 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 texIter = std::find_if(_textures.begin(), _textures.end(), [](const Texture *texture) {
|
||||
auto texIter = std::find_if(_textures.begin(), _textures.end(), [](const Texture *texture) {
|
||||
return texture ? static_cast<const CCWGPUTexture *>(texture)->internalChanged() : false;
|
||||
});
|
||||
|
||||
@@ -221,10 +221,10 @@ void CCWGPUDescriptorSet::prepare() {
|
||||
} else {
|
||||
WGPUBindGroupDescriptor bindGroupDesc = {
|
||||
.nextInChain = nullptr,
|
||||
.label = nullptr,
|
||||
.layout = dsLayout->gpuLayoutEntryObject()->bindGroupLayout,
|
||||
.entryCount = entries.size(),
|
||||
.entries = entries.data(),
|
||||
.label = nullptr,
|
||||
.layout = dsLayout->gpuLayoutEntryObject()->bindGroupLayout,
|
||||
.entryCount = entries.size(),
|
||||
.entries = entries.data(),
|
||||
};
|
||||
_gpuBindGroupObj->bindgroup = wgpuDeviceCreateBindGroup(CCWGPUDevice::getInstance()->gpuDeviceObject()->wgpuDevice, &bindGroupDesc);
|
||||
// _bgl = dsLayout->gpuLayoutEntryObject()->bindGroupLayout;
|
||||
@@ -252,20 +252,20 @@ 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,
|
||||
.size = buffer->getSize(),
|
||||
.offset = buffer->getOffset(),
|
||||
.buffer = buffer->gpuBufferObject()->wgpuBuffer,
|
||||
.size = buffer->getSize(),
|
||||
.offset = buffer->getOffset(),
|
||||
};
|
||||
|
||||
WGPUBindGroupDescriptor bindGroupDesc = {
|
||||
.nextInChain = nullptr,
|
||||
.label = nullptr,
|
||||
.layout = static_cast<WGPUBindGroupLayout>(CCWGPUDescriptorSetLayout::defaultBindGroupLayout()),
|
||||
.entryCount = 1,
|
||||
.entries = &bufferEntry,
|
||||
.label = nullptr,
|
||||
.layout = static_cast<WGPUBindGroupLayout>(CCWGPUDescriptorSetLayout::defaultBindGroupLayout()),
|
||||
.entryCount = 1,
|
||||
.entries = &bufferEntry,
|
||||
};
|
||||
anoymous::defaultBindGroup = wgpuDeviceCreateBindGroup(deviceObj->wgpuDevice, &bindGroupDesc);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user