Skip to content

Commit 7ed6898

Browse files
Record and replay local_read pNexts.
Missed these when sweeping over the exts.
1 parent 623911b commit 7ed6898

File tree

2 files changed

+232
-1
lines changed

2 files changed

+232
-1
lines changed

fossilize.cpp

+202
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,8 @@ struct StateReplayer::Impl
385385
bool parse_sample_locations_info(const Value &state, VkSampleLocationsInfoEXT **out_info) FOSSILIZE_WARN_UNUSED;
386386
bool parse_pipeline_robustness(const Value &state, VkPipelineRobustnessCreateInfoEXT **out_info) FOSSILIZE_WARN_UNUSED;
387387
bool parse_depth_clamp_control(const Value &state, VkPipelineViewportDepthClampControlCreateInfoEXT **out_info) FOSSILIZE_WARN_UNUSED;
388+
bool parse_rendering_attachment_location_info(const Value &state, VkRenderingAttachmentLocationInfoKHR **out_info) FOSSILIZE_WARN_UNUSED;
389+
bool parse_rendering_input_attachment_index_info(const Value &state, VkRenderingInputAttachmentIndexInfoKHR **out_info) FOSSILIZE_WARN_UNUSED;
388390
bool parse_uints(const Value &attachments, const uint32_t **out_uints) FOSSILIZE_WARN_UNUSED;
389391
bool parse_sints(const Value &attachments, const int32_t **out_uints) FOSSILIZE_WARN_UNUSED;
390392
const char *duplicate_string(const char *str, size_t len);
@@ -536,6 +538,10 @@ struct StateRecorder::Impl
536538
void *copy_pnext_struct(const VkPipelineViewportDepthClampControlCreateInfoEXT *create_info,
537539
ScratchAllocator &alloc,
538540
const DynamicStateInfo *dynamic_state_info) FOSSILIZE_WARN_UNUSED;
541+
void *copy_pnext_struct(const VkRenderingAttachmentLocationInfoKHR *create_info,
542+
ScratchAllocator &alloc) FOSSILIZE_WARN_UNUSED;
543+
void *copy_pnext_struct(const VkRenderingInputAttachmentIndexInfoKHR *create_info,
544+
ScratchAllocator &alloc) FOSSILIZE_WARN_UNUSED;
539545
template <typename T>
540546
void *copy_pnext_struct_simple(const T *create_info, ScratchAllocator &alloc) FOSSILIZE_WARN_UNUSED;
541547

@@ -836,6 +842,43 @@ static void hash_pnext_struct(const StateRecorder *, Hasher &h,
836842
h.u32(0);
837843
}
838844

845+
static void hash_pnext_struct(const StateRecorder *, Hasher &h,
846+
const VkRenderingAttachmentLocationInfoKHR &info)
847+
{
848+
h.u32(info.colorAttachmentCount);
849+
if (info.pColorAttachmentLocations)
850+
{
851+
for (uint32_t i = 0; i < info.colorAttachmentCount; i++)
852+
h.u32(info.pColorAttachmentLocations[i]);
853+
}
854+
else
855+
h.u32(0);
856+
}
857+
858+
static void hash_pnext_struct(const StateRecorder *, Hasher &h,
859+
const VkRenderingInputAttachmentIndexInfoKHR &info)
860+
{
861+
h.u32(info.colorAttachmentCount);
862+
863+
if (info.pColorAttachmentInputIndices)
864+
{
865+
for (uint32_t i = 0; i < info.colorAttachmentCount; i++)
866+
h.u32(info.pColorAttachmentInputIndices[i]);
867+
}
868+
else
869+
h.u32(0);
870+
871+
if (info.pDepthInputAttachmentIndex)
872+
h.u32(*info.pDepthInputAttachmentIndex);
873+
else
874+
h.u32(0xffff); // Use an arbitrary invalid attachment value.
875+
876+
if (info.pStencilInputAttachmentIndex)
877+
h.u32(*info.pStencilInputAttachmentIndex);
878+
else
879+
h.u32(0xffff); // Use an arbitrary invalid attachment value.
880+
}
881+
839882
static bool hash_pnext_chain_pdf2(const StateRecorder *recorder, Hasher &h, const void *pNext)
840883
{
841884
while ((pNext = pnext_chain_pdf2_skip_ignored_entries(pNext)) != nullptr)
@@ -1658,6 +1701,14 @@ static bool hash_pnext_chain(const StateRecorder *recorder, Hasher &h, const voi
16581701
hash_pnext_struct(recorder, h, *static_cast<const VkPipelineViewportDepthClampControlCreateInfoEXT *>(pNext), dynamic_state_info);
16591702
break;
16601703

1704+
case VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_LOCATION_INFO_KHR:
1705+
hash_pnext_struct(recorder, h, *static_cast<const VkRenderingAttachmentLocationInfoKHR *>(pNext));
1706+
break;
1707+
1708+
case VK_STRUCTURE_TYPE_RENDERING_INPUT_ATTACHMENT_INDEX_INFO_KHR:
1709+
hash_pnext_struct(recorder, h, *static_cast<const VkRenderingInputAttachmentIndexInfoKHR *>(pNext));
1710+
break;
1711+
16611712
default:
16621713
log_error_pnext_chain("Unsupported pNext found, cannot hash.", pNext);
16631714
return false;
@@ -4819,6 +4870,52 @@ bool StateReplayer::Impl::parse_depth_clamp_control(const Value &state, VkPipeli
48194870
return true;
48204871
}
48214872

4873+
bool StateReplayer::Impl::parse_rendering_attachment_location_info(const Value &state, VkRenderingAttachmentLocationInfoKHR **out_info)
4874+
{
4875+
auto *info = allocator.allocate_cleared<VkRenderingAttachmentLocationInfoKHR>();
4876+
info->colorAttachmentCount = state["colorAttachmentCount"].GetUint();
4877+
if (state.HasMember("colorAttachmentLocations"))
4878+
{
4879+
auto *locs = allocator.allocate_n_cleared<uint32_t>(info->colorAttachmentCount);
4880+
for (uint32_t i = 0; i < info->colorAttachmentCount; i++)
4881+
locs[i] = state["colorAttachmentLocations"][i].GetUint();
4882+
info->pColorAttachmentLocations = locs;
4883+
}
4884+
4885+
*out_info = info;
4886+
return true;
4887+
}
4888+
4889+
bool StateReplayer::Impl::parse_rendering_input_attachment_index_info(const Value &state, VkRenderingInputAttachmentIndexInfoKHR **out_info)
4890+
{
4891+
auto *info = allocator.allocate_cleared<VkRenderingInputAttachmentIndexInfoKHR>();
4892+
info->colorAttachmentCount = state["colorAttachmentCount"].GetUint();
4893+
if (state.HasMember("colorAttachmentInputIndices"))
4894+
{
4895+
auto *locs = allocator.allocate_n<uint32_t>(info->colorAttachmentCount);
4896+
for (uint32_t i = 0; i < info->colorAttachmentCount; i++)
4897+
locs[i] = state["colorAttachmentInputIndices"][i].GetUint();
4898+
info->pColorAttachmentInputIndices = locs;
4899+
}
4900+
4901+
if (state.HasMember("depthInputAttachmentIndex"))
4902+
{
4903+
auto *loc = allocator.allocate<uint32_t>();
4904+
*loc = state["depthInputAttachmentIndex"].GetUint();
4905+
info->pDepthInputAttachmentIndex = loc;
4906+
}
4907+
4908+
if (state.HasMember("stencilInputAttachmentIndex"))
4909+
{
4910+
auto *loc = allocator.allocate<uint32_t>();
4911+
*loc = state["stencilInputAttachmentIndex"].GetUint();
4912+
info->pStencilInputAttachmentIndex = loc;
4913+
}
4914+
4915+
*out_info = info;
4916+
return true;
4917+
}
4918+
48224919
bool StateReplayer::Impl::parse_mutable_descriptor_type(const Value &state,
48234920
VkMutableDescriptorTypeCreateInfoEXT **out_info)
48244921
{
@@ -5245,6 +5342,24 @@ bool StateReplayer::Impl::parse_pnext_chain(
52455342
break;
52465343
}
52475344

5345+
case VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_LOCATION_INFO_KHR:
5346+
{
5347+
VkRenderingAttachmentLocationInfoKHR *info = nullptr;
5348+
if (!parse_rendering_attachment_location_info(next, &info))
5349+
return false;
5350+
new_struct = reinterpret_cast<VkBaseInStructure *>(info);
5351+
break;
5352+
}
5353+
5354+
case VK_STRUCTURE_TYPE_RENDERING_INPUT_ATTACHMENT_INDEX_INFO_KHR:
5355+
{
5356+
VkRenderingInputAttachmentIndexInfoKHR *info = nullptr;
5357+
if (!parse_rendering_input_attachment_index_info(next, &info))
5358+
return false;
5359+
new_struct = reinterpret_cast<VkBaseInStructure *>(info);
5360+
break;
5361+
}
5362+
52485363
default:
52495364
LOGE_LEVEL("Failed to parse pNext chain for sType: %d\n", int(sType));
52505365
return false;
@@ -5907,6 +6022,26 @@ void *StateRecorder::Impl::copy_pnext_struct(const VkPipelineViewportDepthClampC
59076022
return clamp_control;
59086023
}
59096024

6025+
void *StateRecorder::Impl::copy_pnext_struct(const VkRenderingAttachmentLocationInfoKHR *info, ScratchAllocator &alloc)
6026+
{
6027+
auto *loc_info = copy(info, 1, alloc);
6028+
if (loc_info->pColorAttachmentLocations)
6029+
loc_info->pColorAttachmentLocations = copy(loc_info->pColorAttachmentLocations, info->colorAttachmentCount, alloc);
6030+
return loc_info;
6031+
}
6032+
6033+
void *StateRecorder::Impl::copy_pnext_struct(const VkRenderingInputAttachmentIndexInfoKHR *info, ScratchAllocator &alloc)
6034+
{
6035+
auto *loc_info = copy(info, 1, alloc);
6036+
if (loc_info->pColorAttachmentInputIndices)
6037+
loc_info->pColorAttachmentInputIndices = copy(loc_info->pColorAttachmentInputIndices, info->colorAttachmentCount, alloc);
6038+
if (loc_info->pDepthInputAttachmentIndex)
6039+
loc_info->pDepthInputAttachmentIndex = copy(loc_info->pDepthInputAttachmentIndex, 1, alloc);
6040+
if (loc_info->pStencilInputAttachmentIndex)
6041+
loc_info->pStencilInputAttachmentIndex = copy(loc_info->pStencilInputAttachmentIndex, 1, alloc);
6042+
return loc_info;
6043+
}
6044+
59106045
template <typename T>
59116046
void *StateRecorder::Impl::copy_pnext_struct_simple(const T *create_info, ScratchAllocator &alloc)
59126047
{
@@ -6245,6 +6380,20 @@ bool StateRecorder::Impl::copy_pnext_chain(const void *pNext, ScratchAllocator &
62456380
break;
62466381
}
62476382

6383+
case VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_LOCATION_INFO_KHR:
6384+
{
6385+
auto *ci = static_cast<const VkRenderingAttachmentLocationInfoKHR *>(pNext);
6386+
*ppNext = static_cast<VkBaseInStructure *>(copy_pnext_struct(ci, alloc));
6387+
break;
6388+
}
6389+
6390+
case VK_STRUCTURE_TYPE_RENDERING_INPUT_ATTACHMENT_INDEX_INFO_KHR:
6391+
{
6392+
auto *ci = static_cast<const VkRenderingInputAttachmentIndexInfoKHR *>(pNext);
6393+
*ppNext = static_cast<VkBaseInStructure *>(copy_pnext_struct(ci, alloc));
6394+
break;
6395+
}
6396+
62486397
default:
62496398
LOGE_LEVEL("Cannot copy unknown pNext sType: %d.\n", int(pin->sType));
62506399
return false;
@@ -9428,6 +9577,49 @@ static bool json_value(const VkPipelineViewportDepthClampControlCreateInfoEXT &c
94289577
return true;
94299578
}
94309579

9580+
template <typename Allocator>
9581+
static bool json_value(const VkRenderingAttachmentLocationInfoKHR &create_info, Allocator &alloc, Value *out_value)
9582+
{
9583+
Value value(kObjectType);
9584+
value.AddMember("sType", create_info.sType, alloc);
9585+
value.AddMember("colorAttachmentCount", create_info.colorAttachmentCount, alloc);
9586+
9587+
if (create_info.pColorAttachmentLocations)
9588+
{
9589+
Value range(kArrayType);
9590+
for (uint32_t i = 0; i < create_info.colorAttachmentCount; i++)
9591+
range.PushBack(create_info.pColorAttachmentLocations[i], alloc);
9592+
value.AddMember("colorAttachmentLocations", range, alloc);
9593+
}
9594+
9595+
*out_value = value;
9596+
return true;
9597+
}
9598+
9599+
template <typename Allocator>
9600+
static bool json_value(const VkRenderingInputAttachmentIndexInfoKHR &create_info, Allocator &alloc, Value *out_value)
9601+
{
9602+
Value value(kObjectType);
9603+
value.AddMember("sType", create_info.sType, alloc);
9604+
value.AddMember("colorAttachmentCount", create_info.colorAttachmentCount, alloc);
9605+
9606+
if (create_info.pColorAttachmentInputIndices)
9607+
{
9608+
Value range(kArrayType);
9609+
for (uint32_t i = 0; i < create_info.colorAttachmentCount; i++)
9610+
range.PushBack(create_info.pColorAttachmentInputIndices[i], alloc);
9611+
value.AddMember("colorAttachmentInputIndices", range, alloc);
9612+
}
9613+
9614+
if (create_info.pDepthInputAttachmentIndex)
9615+
value.AddMember("depthInputAttachmentIndex", *create_info.pDepthInputAttachmentIndex, alloc);
9616+
if (create_info.pStencilInputAttachmentIndex)
9617+
value.AddMember("stencilInputAttachmentIndex", *create_info.pStencilInputAttachmentIndex, alloc);
9618+
9619+
*out_value = value;
9620+
return true;
9621+
}
9622+
94319623
template <typename Allocator>
94329624
static bool json_value(const VkSubpassDescriptionDepthStencilResolve &create_info, Allocator &alloc, Value *out_value);
94339625
template <typename Allocator>
@@ -9643,6 +9835,16 @@ static bool pnext_chain_json_value(const void *pNext, Allocator &alloc, Value *o
96439835
return false;
96449836
break;
96459837

9838+
case VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_LOCATION_INFO_KHR:
9839+
if (!json_value(*static_cast<const VkRenderingAttachmentLocationInfoKHR *>(pNext), alloc, &next))
9840+
return false;
9841+
break;
9842+
9843+
case VK_STRUCTURE_TYPE_RENDERING_INPUT_ATTACHMENT_INDEX_INFO_KHR:
9844+
if (!json_value(*static_cast<const VkRenderingInputAttachmentIndexInfoKHR *>(pNext), alloc, &next))
9845+
return false;
9846+
break;
9847+
96469848
default:
96479849
log_error_pnext_chain("Unsupported pNext found, cannot hash sType.", pNext);
96489850
return false;

test/fossilize_test.cpp

+30-1
Original file line numberDiff line numberDiff line change
@@ -2283,7 +2283,36 @@ static void record_graphics_pipelines(StateRecorder &recorder)
22832283
if (!recorder.record_graphics_pipeline(fake_handle<VkPipeline>(100013), pipe, nullptr, 0))
22842284
abort();
22852285
range = { 0.8f, 0.2f };
2286-
if (!recorder.record_graphics_pipeline(fake_handle<VkPipeline>(100013), pipe, nullptr, 0))
2286+
if (!recorder.record_graphics_pipeline(fake_handle<VkPipeline>(100014), pipe, nullptr, 0))
2287+
abort();
2288+
2289+
VkRenderingAttachmentLocationInfoKHR attachment_location_info = { VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_LOCATION_INFO_KHR };
2290+
pipe.pNext = &attachment_location_info;
2291+
attachment_location_info.colorAttachmentCount = 1;
2292+
if (!recorder.record_graphics_pipeline(fake_handle<VkPipeline>(100015), pipe, nullptr, 0))
2293+
abort();
2294+
attachment_location_info.colorAttachmentCount = 2;
2295+
if (!recorder.record_graphics_pipeline(fake_handle<VkPipeline>(100016), pipe, nullptr, 0))
2296+
abort();
2297+
2298+
const uint32_t color_locs[] = { 5, 4, UINT32_MAX };
2299+
attachment_location_info.pColorAttachmentLocations = color_locs;
2300+
if (!recorder.record_graphics_pipeline(fake_handle<VkPipeline>(100017), pipe, nullptr, 0))
2301+
abort();
2302+
2303+
VkRenderingInputAttachmentIndexInfoKHR input_attachment_info = { VK_STRUCTURE_TYPE_RENDERING_INPUT_ATTACHMENT_INDEX_INFO_KHR };
2304+
input_attachment_info.colorAttachmentCount = 2;
2305+
pipe.pNext = &input_attachment_info;
2306+
if (!recorder.record_graphics_pipeline(fake_handle<VkPipeline>(100018), pipe, nullptr, 0))
2307+
abort();
2308+
input_attachment_info.pColorAttachmentInputIndices = color_locs;
2309+
if (!recorder.record_graphics_pipeline(fake_handle<VkPipeline>(100019), pipe, nullptr, 0))
2310+
abort();
2311+
input_attachment_info.pDepthInputAttachmentIndex = color_locs + 1;
2312+
if (!recorder.record_graphics_pipeline(fake_handle<VkPipeline>(100020), pipe, nullptr, 0))
2313+
abort();
2314+
input_attachment_info.pStencilInputAttachmentIndex = color_locs + 2;
2315+
if (!recorder.record_graphics_pipeline(fake_handle<VkPipeline>(100021), pipe, nullptr, 0))
22872316
abort();
22882317
}
22892318

0 commit comments

Comments
 (0)