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];
0 commit comments