Skip to content

Commit f1ead19

Browse files
committed
Get rid of QueryInterface
1 parent a62e1ab commit f1ead19

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+328
-329
lines changed

src/FlyCube/Adapter/Adapter.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#pragma once
22
#include "Device/Device.h"
3-
#include "Instance/QueryInterface.h"
43

54
#include <memory>
65
#include <string>
76

8-
class Adapter : public QueryInterface {
7+
class Adapter {
98
public:
109
virtual ~Adapter() = default;
1110
virtual const std::string& GetName() const = 0;

src/FlyCube/BindingSet/BindingSet.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#pragma once
22
#include "Instance/BaseTypes.h"
3-
#include "Instance/QueryInterface.h"
43

5-
class BindingSet : public QueryInterface {
4+
class BindingSet {
65
public:
76
virtual ~BindingSet() = default;
87
virtual void WriteBindings(const WriteBindingsDesc& desc) = 0;

src/FlyCube/BindingSet/DXBindingSet.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "BindingSetLayout/DXBindingSetLayout.h"
44
#include "Device/DXDevice.h"
55
#include "GPUDescriptorPool/DXGPUDescriptorPoolRange.h"
6+
#include "Utilities/Cast.h"
67
#include "View/DXView.h"
78

89
namespace {
@@ -128,6 +129,6 @@ void DXBindingSet::WriteDescriptor(const BindingDesc& binding)
128129
{
129130
decltype(auto) binding_layout = layout_->GetLayout().at(binding.bind_key);
130131
std::shared_ptr<DXGPUDescriptorPoolRange> heap_range = descriptor_ranges_.at(binding_layout.heap_type);
131-
decltype(auto) src_cpu_handle = binding.view->As<DXView>().GetHandle();
132+
decltype(auto) src_cpu_handle = CastToImpl<DXView>(binding.view)->GetHandle();
132133
heap_range->CopyCpuHandle(binding_layout.heap_offset, src_cpu_handle);
133134
}

src/FlyCube/BindingSet/MTBindingSet.mm

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "Device/MTDevice.h"
55
#include "Pipeline/MTPipeline.h"
66
#include "Shader/MTShader.h"
7+
#include "Utilities/Cast.h"
78
#include "Utilities/NotReached.h"
89
#include "View/MTView.h"
910

@@ -92,11 +93,11 @@ void SetView(id<MTL4ArgumentTable> argument_table, const std::shared_ptr<MTView>
9293
id<MTLResidencySet> residency_set)
9394
{
9495
for (const auto& [bind_key, view] : direct_bindings_) {
95-
decltype(auto) shader = pipeline->As<MTPipeline>().GetShader(bind_key.shader_type);
96-
uint32_t index = shader->As<MTShader>().GetIndex(bind_key);
96+
decltype(auto) shader = CastToImpl<MTPipeline>(pipeline)->GetShader(bind_key.shader_type);
97+
uint32_t index = CastToImpl<MTShader>(shader)->GetIndex(bind_key);
9798
SetView(argument_tables.at(bind_key.shader_type), std::static_pointer_cast<MTView>(view), index);
9899
if (view) {
99-
id<MTLResource> resource = view->As<MTView>().GetNativeResource();
100+
id<MTLResource> resource = CastToImpl<MTView>(view)->GetNativeResource();
100101
if (resource) {
101102
[residency_set addAllocation:resource];
102103
}
@@ -109,8 +110,8 @@ void SetView(id<MTL4ArgumentTable> argument_table, const std::shared_ptr<MTView>
109110

110111
id<MTLBuffer> buffer = device_.GetBindlessArgumentBuffer().GetArgumentBuffer();
111112
for (const auto& bind_key : bindless_bind_keys_) {
112-
decltype(auto) shader = pipeline->As<MTPipeline>().GetShader(bind_key.shader_type);
113-
uint32_t index = shader->As<MTShader>().GetIndex(bind_key);
113+
decltype(auto) shader = CastToImpl<MTPipeline>(pipeline)->GetShader(bind_key.shader_type);
114+
uint32_t index = CastToImpl<MTShader>(shader)->GetIndex(bind_key);
114115
SetBuffer(argument_tables.at(bind_key.shader_type), buffer, 0, index);
115116
}
116117
[residency_set addAllocation:buffer];

src/FlyCube/BindingSet/VKBindingSet.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "BindingSetLayout/VKBindingSetLayout.h"
44
#include "Device/VKDevice.h"
5+
#include "Utilities/Cast.h"
56
#include "View/VKView.h"
67

78
#include <deque>
@@ -73,8 +74,8 @@ const std::vector<vk::DescriptorSet>& VKBindingSet::GetDescriptorSets() const
7374

7475
void VKBindingSet::WriteDescriptor(std::vector<vk::WriteDescriptorSet>& descriptors, const BindingDesc& binding)
7576
{
76-
decltype(auto) vk_view = binding.view->As<VKView>();
77-
vk::WriteDescriptorSet descriptor = vk_view.GetDescriptor();
77+
decltype(auto) vk_view = CastToImpl<VKView>(binding.view);
78+
vk::WriteDescriptorSet descriptor = vk_view->GetDescriptor();
7879
descriptor.descriptorType = GetDescriptorType(binding.bind_key.view_type);
7980
descriptor.dstSet = descriptor_sets_[binding.bind_key.space];
8081
descriptor.dstBinding = binding.bind_key.slot;
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#pragma once
22
#include "Instance/BaseTypes.h"
3-
#include "Instance/QueryInterface.h"
43

5-
class BindingSetLayout : public QueryInterface {
4+
class BindingSetLayout {
65
public:
76
virtual ~BindingSetLayout() = default;
87
};

src/FlyCube/BindlessTypedViewPool/BindlessTypedViewPool.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
#pragma once
2-
#include "Instance/QueryInterface.h"
32

43
#include <cstdint>
54
#include <memory>
65

76
class View;
87

9-
class BindlessTypedViewPool : public QueryInterface {
8+
class BindlessTypedViewPool {
109
public:
1110
virtual ~BindlessTypedViewPool() = default;
1211
virtual uint32_t GetBaseDescriptorId() const = 0;

src/FlyCube/BindlessTypedViewPool/DXBindlessTypedViewPool.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "BindlessTypedViewPool/DXBindlessTypedViewPool.h"
22

33
#include "Device/DXDevice.h"
4+
#include "Utilities/Cast.h"
45
#include "Utilities/Check.h"
56
#include "Utilities/NotReached.h"
67
#include "View/DXView.h"
@@ -45,11 +46,11 @@ uint32_t DXBindlessTypedViewPool::GetViewCount() const
4546

4647
void DXBindlessTypedViewPool::WriteView(uint32_t index, const std::shared_ptr<View>& view)
4748
{
48-
WriteViewImpl(index, view->As<DXView>());
49+
WriteViewImpl(index, CastToImpl<DXView>(view));
4950
}
5051

51-
void DXBindlessTypedViewPool::WriteViewImpl(uint32_t index, DXView& view)
52+
void DXBindlessTypedViewPool::WriteViewImpl(uint32_t index, DXView* view)
5253
{
5354
DCHECK(index < view_count_);
54-
range_->CopyCpuHandle(index, view.GetHandle());
55+
range_->CopyCpuHandle(index, view->GetHandle());
5556
}

src/FlyCube/BindlessTypedViewPool/DXBindlessTypedViewPool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class DXBindlessTypedViewPool : public BindlessTypedViewPool {
1414
uint32_t GetViewCount() const override;
1515
void WriteView(uint32_t index, const std::shared_ptr<View>& view) override;
1616

17-
void WriteViewImpl(uint32_t index, DXView& view);
17+
void WriteViewImpl(uint32_t index, DXView* view);
1818

1919
private:
2020
uint32_t view_count_;

src/FlyCube/BindlessTypedViewPool/MTBindlessTypedViewPool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class MTBindlessTypedViewPool : public BindlessTypedViewPool {
1414
uint32_t GetViewCount() const override;
1515
void WriteView(uint32_t index, const std::shared_ptr<View>& view) override;
1616

17-
void WriteViewImpl(uint32_t index, MTView& view);
17+
void WriteViewImpl(uint32_t index, MTView* view);
1818

1919
private:
2020
uint32_t view_count_;

0 commit comments

Comments
 (0)