@@ -155,13 +155,13 @@ void Ray::Vk::TransitionResourceStates(VkCommandBuffer cmd_buf, const Bitmask<eS
155155 const Context *ctx = nullptr ;
156156
157157 for (const TransitionInfo &transition : transitions) {
158- if (transition.p_tex && *transition.p_tex ) {
159- ctx = transition.p_tex ->ctx ();
158+ if (std::holds_alternative< const Texture *>( transition.p_res ) && *std::get< const Texture *>( transition.p_res ) ) {
159+ ctx = std::get< const Texture *>( transition.p_res ) ->ctx ();
160160
161161 eResState old_state = transition.old_state ;
162162 if (old_state == eResState::Undefined) {
163163 // take state from resource itself
164- old_state = transition.p_tex ->resource_state ;
164+ old_state = std::get< const Texture *>( transition.p_res ) ->resource_state ;
165165 if (old_state != eResState::Undefined && old_state == transition.new_state &&
166166 old_state != eResState::UnorderedAccess) {
167167 // transition is not needed
@@ -177,10 +177,10 @@ void Ray::Vk::TransitionResourceStates(VkCommandBuffer cmd_buf, const Bitmask<eS
177177 new_barrier.newLayout = VKImageLayoutForState (transition.new_state );
178178 new_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED ;
179179 new_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED ;
180- new_barrier.image = transition.p_tex ->handle ().img ;
181- if (IsDepthStencilFormat (transition.p_tex ->params .format )) {
180+ new_barrier.image = std::get< const Texture *>( transition.p_res ) ->handle ().img ;
181+ if (IsDepthStencilFormat (std::get< const Texture *>( transition.p_res ) ->params .format )) {
182182 new_barrier.subresourceRange .aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT ;
183- } else if (IsDepthFormat (transition.p_tex ->params .format )) {
183+ } else if (IsDepthFormat (std::get< const Texture *>( transition.p_res ) ->params .format )) {
184184 new_barrier.subresourceRange .aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT ;
185185 } else {
186186 new_barrier.subresourceRange .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT ;
@@ -195,15 +195,16 @@ void Ray::Vk::TransitionResourceStates(VkCommandBuffer cmd_buf, const Bitmask<eS
195195 dst_stages |= VKPipelineStagesForState (transition.new_state );
196196
197197 if (transition.update_internal_state ) {
198- transition.p_tex ->resource_state = transition.new_state ;
198+ std::get< const Texture *>( transition.p_res ) ->resource_state = transition.new_state ;
199199 }
200- } else if (transition.p_buf && *transition.p_buf ) {
201- ctx = transition.p_buf ->ctx ();
200+ } else if (std::holds_alternative<const Buffer *>(transition.p_res ) &&
201+ *std::get<const Buffer *>(transition.p_res )) {
202+ ctx = std::get<const Buffer *>(transition.p_res )->ctx ();
202203
203204 eResState old_state = transition.old_state ;
204205 if (old_state == eResState::Undefined) {
205206 // take state from resource itself
206- old_state = transition.p_buf ->resource_state ;
207+ old_state = std::get< const Buffer *>( transition.p_res ) ->resource_state ;
207208 if (old_state == transition.new_state && old_state != eResState::UnorderedAccess) {
208209 // transition is not needed
209210 continue ;
@@ -216,7 +217,7 @@ void Ray::Vk::TransitionResourceStates(VkCommandBuffer cmd_buf, const Bitmask<eS
216217 new_barrier.dstAccessMask = VKAccessFlagsForState (transition.new_state );
217218 new_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED ;
218219 new_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED ;
219- new_barrier.buffer = transition.p_buf ->vk_handle ();
220+ new_barrier.buffer = std::get< const Buffer *>( transition.p_res ) ->vk_handle ();
220221 // transition whole buffer for now
221222 new_barrier.offset = 0 ;
222223 new_barrier.size = VK_WHOLE_SIZE ;
@@ -225,15 +226,16 @@ void Ray::Vk::TransitionResourceStates(VkCommandBuffer cmd_buf, const Bitmask<eS
225226 dst_stages |= VKPipelineStagesForState (transition.new_state );
226227
227228 if (transition.update_internal_state ) {
228- transition.p_buf ->resource_state = transition.new_state ;
229+ std::get< const Buffer *>( transition.p_res ) ->resource_state = transition.new_state ;
229230 }
230- } else if (transition.p_tex_arr && transition.p_tex_arr ->page_count ()) {
231- ctx = transition.p_tex_arr ->ctx ();
231+ } else if (std::holds_alternative<const TextureAtlas *>(transition.p_res ) &&
232+ std::get<const TextureAtlas *>(transition.p_res )->page_count ()) {
233+ ctx = std::get<const TextureAtlas *>(transition.p_res )->ctx ();
232234
233235 eResState old_state = transition.old_state ;
234236 if (old_state == eResState::Undefined) {
235237 // take state from resource itself
236- old_state = transition.p_tex_arr ->resource_state ;
238+ old_state = std::get< const TextureAtlas *>( transition.p_res ) ->resource_state ;
237239 if (old_state != eResState::Undefined && old_state == transition.new_state &&
238240 old_state != eResState::UnorderedAccess) {
239241 // transition is not needed
@@ -249,7 +251,7 @@ void Ray::Vk::TransitionResourceStates(VkCommandBuffer cmd_buf, const Bitmask<eS
249251 new_barrier.newLayout = VKImageLayoutForState (transition.new_state );
250252 new_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED ;
251253 new_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED ;
252- new_barrier.image = transition.p_tex_arr ->vk_image ();
254+ new_barrier.image = std::get< const TextureAtlas *>( transition.p_res ) ->vk_image ();
253255 new_barrier.subresourceRange .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT ;
254256
255257 // transition whole image for now
@@ -262,7 +264,7 @@ void Ray::Vk::TransitionResourceStates(VkCommandBuffer cmd_buf, const Bitmask<eS
262264 dst_stages |= VKPipelineStagesForState (transition.new_state );
263265
264266 if (transition.update_internal_state ) {
265- transition.p_tex_arr ->resource_state = transition.new_state ;
267+ std::get< const TextureAtlas *>( transition.p_res ) ->resource_state = transition.new_state ;
266268 }
267269 }
268270 }
0 commit comments