mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-20 18:29:23 +00:00
Use TypedInteger for BindGroupIndex
Bug: dawn:442 Change-Id: I889a943cbaf2d349c31a15fdf126d66964bdd0a7 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/23247 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Stephen White <senorblanco@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
e5d94c31a0
commit
250f26229b
@@ -225,7 +225,8 @@ namespace dawn_native { namespace opengl {
|
||||
}
|
||||
|
||||
void Apply(const OpenGLFunctions& gl) {
|
||||
for (uint32_t index : IterateBitSet(mDirtyBindGroupsObjectChangedOrIsDynamic)) {
|
||||
for (BindGroupIndex index :
|
||||
IterateBitSet(mDirtyBindGroupsObjectChangedOrIsDynamic)) {
|
||||
ApplyBindGroup(gl, index, mBindGroups[index], mDynamicOffsetCounts[index],
|
||||
mDynamicOffsets[index].data());
|
||||
}
|
||||
@@ -234,7 +235,7 @@ namespace dawn_native { namespace opengl {
|
||||
|
||||
private:
|
||||
void ApplyBindGroup(const OpenGLFunctions& gl,
|
||||
uint32_t index,
|
||||
BindGroupIndex index,
|
||||
BindGroupBase* group,
|
||||
uint32_t dynamicOffsetCount,
|
||||
uint64_t* dynamicOffsets) {
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace dawn_native { namespace opengl {
|
||||
// etc.
|
||||
const auto& indices = layout->GetBindingIndexInfo();
|
||||
|
||||
for (uint32_t group : IterateBitSet(layout->GetBindGroupLayoutsMask())) {
|
||||
for (BindGroupIndex group : IterateBitSet(layout->GetBindGroupLayoutsMask())) {
|
||||
const BindGroupLayoutBase* bgl = layout->GetBindGroupLayout(group);
|
||||
|
||||
for (const auto& it : bgl->GetBindingMap()) {
|
||||
|
||||
@@ -36,8 +36,9 @@ namespace dawn_native { namespace opengl {
|
||||
const PipelineLayout* layout,
|
||||
const PerStage<const ShaderModule*>& modules);
|
||||
|
||||
using BindingLocations =
|
||||
std::array<std::array<GLint, kMaxBindingsPerGroup>, kMaxBindGroups>;
|
||||
using BindingLocations = ityp::array<BindGroupIndex,
|
||||
ityp::array<BindingIndex, GLint, kMaxBindingsPerGroup>,
|
||||
kMaxBindGroups>;
|
||||
|
||||
// For each unit a sampler is bound to we need to know if we should use filtering or not
|
||||
// because int and uint texture are only complete without filtering.
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace dawn_native { namespace opengl {
|
||||
GLuint ssboIndex = 0;
|
||||
GLuint storageTextureIndex = 0;
|
||||
|
||||
for (uint32_t group : IterateBitSet(GetBindGroupLayoutsMask())) {
|
||||
for (BindGroupIndex group : IterateBitSet(GetBindGroupLayoutsMask())) {
|
||||
const BindGroupLayoutBase* bgl = GetBindGroupLayout(group);
|
||||
|
||||
for (BindingIndex bindingIndex{0}; bindingIndex < bgl->GetBindingCount();
|
||||
|
||||
@@ -30,7 +30,9 @@ namespace dawn_native { namespace opengl {
|
||||
PipelineLayout(Device* device, const PipelineLayoutDescriptor* descriptor);
|
||||
|
||||
using BindingIndexInfo =
|
||||
std::array<ityp::array<BindingIndex, GLuint, kMaxBindingsPerGroup>, kMaxBindGroups>;
|
||||
ityp::array<BindGroupIndex,
|
||||
ityp::array<BindingIndex, GLuint, kMaxBindingsPerGroup>,
|
||||
kMaxBindGroups>;
|
||||
const BindingIndexInfo& GetBindingIndexInfo() const;
|
||||
|
||||
GLuint GetTextureUnitsUsed() const;
|
||||
|
||||
@@ -24,9 +24,10 @@
|
||||
|
||||
namespace dawn_native { namespace opengl {
|
||||
|
||||
std::string GetBindingName(uint32_t group, BindingNumber bindingNumber) {
|
||||
std::string GetBindingName(BindGroupIndex group, BindingNumber bindingNumber) {
|
||||
std::ostringstream o;
|
||||
o << "dawn_binding_" << group << "_" << static_cast<uint32_t>(bindingNumber);
|
||||
o << "dawn_binding_" << static_cast<uint32_t>(group) << "_"
|
||||
<< static_cast<uint32_t>(bindingNumber);
|
||||
return o.str();
|
||||
}
|
||||
|
||||
@@ -42,8 +43,9 @@ namespace dawn_native { namespace opengl {
|
||||
std::string CombinedSampler::GetName() const {
|
||||
std::ostringstream o;
|
||||
o << "dawn_combined";
|
||||
o << "_" << samplerLocation.group << "_" << static_cast<uint32_t>(samplerLocation.binding);
|
||||
o << "_with_" << textureLocation.group << "_"
|
||||
o << "_" << static_cast<uint32_t>(samplerLocation.group) << "_"
|
||||
<< static_cast<uint32_t>(samplerLocation.binding);
|
||||
o << "_with_" << static_cast<uint32_t>(textureLocation.group) << "_"
|
||||
<< static_cast<uint32_t>(textureLocation.binding);
|
||||
return o.str();
|
||||
}
|
||||
@@ -141,16 +143,20 @@ namespace dawn_native { namespace opengl {
|
||||
mCombinedInfo.emplace_back();
|
||||
auto& info = mCombinedInfo.back();
|
||||
|
||||
uint32_t samplerGroup;
|
||||
mSpvcContext.GetDecoration(sampler.sampler_id,
|
||||
shaderc_spvc_decoration_descriptorset,
|
||||
&info.samplerLocation.group);
|
||||
shaderc_spvc_decoration_descriptorset, &samplerGroup);
|
||||
info.samplerLocation.group = BindGroupIndex(samplerGroup);
|
||||
|
||||
uint32_t samplerBinding;
|
||||
mSpvcContext.GetDecoration(sampler.sampler_id, shaderc_spvc_decoration_binding,
|
||||
&samplerBinding);
|
||||
info.samplerLocation.binding = BindingNumber(samplerBinding);
|
||||
|
||||
uint32_t textureGroup;
|
||||
mSpvcContext.GetDecoration(sampler.image_id, shaderc_spvc_decoration_descriptorset,
|
||||
&info.textureLocation.group);
|
||||
&textureGroup);
|
||||
info.textureLocation.group = BindGroupIndex(textureGroup);
|
||||
|
||||
uint32_t textureBinding;
|
||||
mSpvcContext.GetDecoration(sampler.image_id, shaderc_spvc_decoration_binding,
|
||||
@@ -164,12 +170,12 @@ namespace dawn_native { namespace opengl {
|
||||
mCombinedInfo.emplace_back();
|
||||
|
||||
auto& info = mCombinedInfo.back();
|
||||
info.samplerLocation.group =
|
||||
compiler->get_decoration(combined.sampler_id, spv::DecorationDescriptorSet);
|
||||
info.samplerLocation.group = BindGroupIndex(
|
||||
compiler->get_decoration(combined.sampler_id, spv::DecorationDescriptorSet));
|
||||
info.samplerLocation.binding = BindingNumber(
|
||||
compiler->get_decoration(combined.sampler_id, spv::DecorationBinding));
|
||||
info.textureLocation.group =
|
||||
compiler->get_decoration(combined.image_id, spv::DecorationDescriptorSet);
|
||||
info.textureLocation.group = BindGroupIndex(
|
||||
compiler->get_decoration(combined.image_id, spv::DecorationDescriptorSet));
|
||||
info.textureLocation.binding = BindingNumber(
|
||||
compiler->get_decoration(combined.image_id, spv::DecorationBinding));
|
||||
compiler->set_name(combined.combined_id, info.GetName());
|
||||
@@ -179,7 +185,7 @@ namespace dawn_native { namespace opengl {
|
||||
// Change binding names to be "dawn_binding_<group>_<binding>".
|
||||
// Also unsets the SPIRV "Binding" decoration as it outputs "layout(binding=)" which
|
||||
// isn't supported on OSX's OpenGL.
|
||||
for (uint32_t group = 0; group < kMaxBindGroups; ++group) {
|
||||
for (BindGroupIndex group(0); group < kMaxBindGroupsTyped; ++group) {
|
||||
for (const auto& it : bindingInfo[group]) {
|
||||
BindingNumber bindingNumber = it.first;
|
||||
const auto& info = it.second;
|
||||
|
||||
@@ -23,10 +23,10 @@ namespace dawn_native { namespace opengl {
|
||||
|
||||
class Device;
|
||||
|
||||
std::string GetBindingName(uint32_t group, BindingNumber bindingNumber);
|
||||
std::string GetBindingName(BindGroupIndex group, BindingNumber bindingNumber);
|
||||
|
||||
struct BindingLocation {
|
||||
uint32_t group;
|
||||
BindGroupIndex group;
|
||||
BindingNumber binding;
|
||||
};
|
||||
bool operator<(const BindingLocation& a, const BindingLocation& b);
|
||||
|
||||
Reference in New Issue
Block a user