Skip to content

Commit b2bf654

Browse files
layers: Use ostringstream over stringstream (#11344)
1 parent 10b81cb commit b2bf654

File tree

79 files changed

+257
-257
lines changed

Some content is hidden

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

79 files changed

+257
-257
lines changed

layers/best_practices/bp_descriptor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ bool BestPractices::PreCallValidateCreateDescriptorPool(VkDevice device, const V
171171

172172
const auto* mutable_descriptor_type_ci = vku::FindStructInPNextChain<VkMutableDescriptorTypeCreateInfoEXT>(pCreateInfo->pNext);
173173
if (mutable_descriptor_type_ci && mutable_descriptor_type_ci->mutableDescriptorTypeListCount > pCreateInfo->poolSizeCount) {
174-
std::stringstream msg;
174+
std::ostringstream msg;
175175
if (pCreateInfo->poolSizeCount == 1) {
176176
msg << "first element";
177177
} else {

layers/best_practices/bp_utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const char* VendorSpecificTag(BPVendorFlags vendors) {
5050
auto res = tag_map.find(vendors);
5151
if (res == tag_map.end()) {
5252
// Build the vendor tag string
53-
std::stringstream vendor_tag;
53+
std::ostringstream vendor_tag;
5454

5555
vendor_tag << "[";
5656
bool first_vendor = true;

layers/containers/range.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ class range_view {
126126

127127
template <typename Range>
128128
std::string string_range(const Range &range) {
129-
std::stringstream ss;
129+
std::ostringstream ss;
130130
ss << "[" << range.begin << ", " << range.end << ')';
131131
return ss.str();
132132
}
133133

134134
template <typename Range>
135135
std::string string_range_hex(const Range &range) {
136-
std::stringstream ss;
136+
std::ostringstream ss;
137137
ss << std::hex << "[0x" << range.begin << ", 0x" << range.end << ')';
138138
return ss.str();
139139
}

layers/core_checks/cc_buffer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ bool CoreChecks::PreCallValidateCreateBufferView(VkDevice device, const VkBuffer
269269
alignment_requirement = std::min(alignment_requirement, texel_block_size);
270270
}
271271
if (!IsIntegerMultipleOf(pCreateInfo->offset, alignment_requirement)) {
272-
std::stringstream ss;
272+
std::ostringstream ss;
273273
ss << "was created with VK_BUFFER_USAGE_2_STORAGE_TEXEL_BUFFER_BIT, so the offset (" << pCreateInfo->offset
274274
<< ") must be a multiple of " << alignment_requirement << "\n";
275275
if (phys_dev_props_core13.storageTexelBufferOffsetSingleTexelAlignment) {
@@ -297,7 +297,7 @@ bool CoreChecks::PreCallValidateCreateBufferView(VkDevice device, const VkBuffer
297297
alignment_requirement = std::min(alignment_requirement, texel_block_size);
298298
}
299299
if (!IsIntegerMultipleOf(pCreateInfo->offset, alignment_requirement)) {
300-
std::stringstream ss;
300+
std::ostringstream ss;
301301
ss << "was created with VK_BUFFER_USAGE_2_UNIFORM_TEXEL_BUFFER_BIT, so the offset (" << pCreateInfo->offset
302302
<< ") must be a multiple of " << alignment_requirement << "\n";
303303
if (phys_dev_props_core13.uniformTexelBufferOffsetSingleTexelAlignment) {

layers/core_checks/cc_buffer_address.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class BufferAddressValidation {
100100
vvl::span<vvl::Buffer* const> buffer_list = validator.GetBuffersByAddress(device_address);
101101
if (buffer_list.empty()) {
102102
NearestBufferResult nearest = validator.GetNearestBuffersByAddress(device_address);
103-
std::stringstream ss;
103+
std::ostringstream ss;
104104
ss << "(0x" << std::hex << device_address
105105
<< ") is not a valid buffer address. No call to vkGetBufferDeviceAddress has this buffer in its range.";
106106
if (!nearest.above_buffers.empty()) {
@@ -196,7 +196,7 @@ bool BufferAddressValidation<ChecksCount>::LogInvalidBuffers(const CoreChecks& v
196196
// Some checks only care about the address, but for those that have a range, print it here so it is the same across all error
197197
// messages
198198
if (range_size != 0) {
199-
std::stringstream ss;
199+
std::ostringstream ss;
200200
ss << "[0x" << std::hex << device_address << ", 0x" << (device_address + range_size) << ") (";
201201
if (range_size == VK_WHOLE_SIZE) {
202202
ss << "VK_WHOLE_SIZE";
@@ -213,7 +213,7 @@ bool BufferAddressValidation<ChecksCount>::LogInvalidBuffers(const CoreChecks& v
213213
}
214214
error_msg_beginning = ss.str();
215215
} else {
216-
std::stringstream ss;
216+
std::ostringstream ss;
217217
ss << "(0x" << std::hex << device_address << ") has no buffer(s) associated that are valid.\n";
218218
error_msg_beginning = ss.str();
219219
}

layers/core_checks/cc_cmd_buffer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ bool CoreChecks::ValidateCmd(const vvl::CommandBuffer &cb_state, const Location
108108

109109
// This is a single location to report when a command buffer is invalid (which means it is not in a "recording state")
110110
bool CoreChecks::ReportInvalidCommandBuffer(const vvl::CommandBuffer &cb_state, const Location &loc, const char *vuid) const {
111-
std::stringstream ss;
111+
std::ostringstream ss;
112112
ss << "was called in " << FormatHandle(cb_state) << " which ";
113113

114114
assert(cb_state.state == CbState::InvalidIncomplete || cb_state.state == CbState::InvalidComplete);
@@ -966,7 +966,7 @@ class CoreChecks::ViewportScissorInheritanceTracker {
966966
break;
967967
}
968968

969-
std::stringstream ss;
969+
std::ostringstream ss;
970970
ss << "(" << log_.FormatHandle(secondary_state.Handle()).c_str() << ") consume inherited " << state_name << " ";
971971
if (format_index) {
972972
if (index >= static_use_count) {

layers/core_checks/cc_cmd_buffer_dynamic.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,7 @@ bool CoreChecks::ValidateDrawRenderingAttachmentLocation(const vvl::CommandBuffe
13401340
uint32_t pipeline_color_location = pipeline_color_locations ? pipeline_color_locations[i] : i;
13411341
if (pipeline_color_location != cb_state.rendering_attachments.color_locations[i]) {
13421342
const LogObjectList objlist(cb_state.Handle(), pipeline_state.Handle());
1343-
std::stringstream ss;
1343+
std::ostringstream ss;
13441344
ss << "The pipeline VkRenderingAttachmentLocationInfo::pColorAttachmentLocations[" << i << "] is "
13451345
<< pipeline_color_location;
13461346
if (!explicit_pipeline) {
@@ -1395,7 +1395,7 @@ bool CoreChecks::ValidateDrawRenderingInputAttachmentIndex(const vvl::CommandBuf
13951395
uint32_t pipeline_color_index = pipeline_color_indexes ? pipeline_color_indexes[i] : i;
13961396
if (pipeline_color_index != cb_state.rendering_attachments.color_indexes[i]) {
13971397
const LogObjectList objlist(cb_state.Handle(), pipeline_state.Handle());
1398-
std::stringstream ss;
1398+
std::ostringstream ss;
13991399
ss << "The pipeline VkRenderingInputAttachmentIndexInfo::pColorAttachmentInputIndices[" << i << "] is "
14001400
<< pipeline_color_index;
14011401
if (!explicit_pipeline) {
@@ -1414,7 +1414,7 @@ bool CoreChecks::ValidateDrawRenderingInputAttachmentIndex(const vvl::CommandBuf
14141414

14151415
if (!EqualValuesOrBothNull(pipeline_depth_index, cb_state.rendering_attachments.depth_index)) {
14161416
const LogObjectList objlist(cb_state.Handle(), pipeline_state.Handle());
1417-
std::stringstream ss;
1417+
std::ostringstream ss;
14181418
ss << "The pipeline VkRenderingInputAttachmentIndexInfo::pDepthInputAttachmentIndex is "
14191419
<< string_AttachmentPointer(pipeline_depth_index);
14201420
if (!explicit_pipeline) {
@@ -1431,7 +1431,7 @@ bool CoreChecks::ValidateDrawRenderingInputAttachmentIndex(const vvl::CommandBuf
14311431

14321432
if (!EqualValuesOrBothNull(pipeline_stencil_index, cb_state.rendering_attachments.stencil_index)) {
14331433
const LogObjectList objlist(cb_state.Handle(), pipeline_state.Handle());
1434-
std::stringstream ss;
1434+
std::ostringstream ss;
14351435
ss << "The pipeline VkRenderingInputAttachmentIndexInfo::pStencilInputAttachmentIndex is "
14361436
<< string_AttachmentPointer(pipeline_stencil_index);
14371437
if (!explicit_pipeline) {

layers/core_checks/cc_copy_blit_resolve.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct ImageRegionIntersection {
4545
VkExtent3D extent = {1, 1, 1};
4646
bool has_intersection = false;
4747
std::string String() const noexcept {
48-
std::stringstream ss;
48+
std::ostringstream ss;
4949
ss << "\nsubresource : { aspectMask: " << string_VkImageAspectFlags(subresource.aspectMask)
5050
<< ", mipLevel: " << subresource.mipLevel << ", baseArrayLayer: " << subresource.baseArrayLayer
5151
<< ", layerCount: " << subresource.layerCount << " },\noffset : {" << string_VkOffset3D(offset) << "},\nextent : {"
@@ -272,7 +272,7 @@ bool CoreChecks::ValidateTransferGranularityExtent(const LogObjectList &objlist,
272272
}
273273

274274
if (!(x_ok && y_ok && z_ok)) {
275-
std::stringstream ss;
275+
std::ostringstream ss;
276276
ss << "(" << string_VkExtent3D(region_extent)
277277
<< ") is invalid with this command buffer's queue family minImageTransferGranularity ("
278278
<< string_VkExtent3D(granularity) << ") for copying to/from " << FormatHandle(image_state) << " ("
@@ -330,7 +330,7 @@ static std::string DescribeValidAspectMaskForFormat(VkFormat format) {
330330
aspect_mask |= VK_IMAGE_ASPECT_PLANE_2_BIT;
331331
}
332332

333-
std::stringstream ss;
333+
std::ostringstream ss;
334334
ss << "Valid VkImageAspectFlags are " << string_VkImageAspectFlags(aspect_mask);
335335
return ss.str();
336336
}
@@ -421,14 +421,14 @@ struct ImageCopyRegion {
421421
}
422422

423423
std::string DescribeSrcAndDstImage() const {
424-
std::stringstream ss;
424+
std::ostringstream ss;
425425
ss << "srcImage: " << src_state.DescribeSubresourceLayers(src_subresource)
426426
<< "dstImage: " << dst_state.DescribeSubresourceLayers(dst_subresource);
427427
return ss.str();
428428
}
429429

430430
std::string DescribeAdjustedExtent() const {
431-
std::stringstream ss;
431+
std::ostringstream ss;
432432
if (is_adjusted_extent) {
433433
ss << "The VkImageCopy::extent [" << string_VkExtent3D(extent) << "] is adjusted to ["
434434
<< string_VkExtent3D(dst_adjusted_extent) << "] because it is going from ";
@@ -1536,7 +1536,7 @@ bool CoreChecks::ValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage src
15361536
const bool exception = src_image_type != dst_image_type && src_layer_count == VK_REMAINING_ARRAY_LAYERS &&
15371537
dst_layer_count == VK_REMAINING_ARRAY_LAYERS;
15381538
if (!exception && normalized_src_layer_count != normalized_dst_layer_count) {
1539-
std::stringstream ss;
1539+
std::ostringstream ss;
15401540
ss << "(" << string_LayerCount(src_image_state->create_info, src_subresource) << ") does not match "
15411541
<< dst_subresource_loc.dot(Field::layerCount).Fields() << " ("
15421542
<< string_LayerCount(dst_image_state->create_info, dst_subresource) << ").";
@@ -1685,7 +1685,7 @@ bool CoreChecks::ValidateCmdCopyImage(VkCommandBuffer commandBuffer, VkImage src
16851685
// If size is still zero, then format is invalid and will be caught in another VU
16861686
if ((src_format_size != dst_format_size) && (src_format_size != 0) && (dst_format_size != 0)) {
16871687
vuid = is_2 ? "VUID-VkCopyImageInfo2-None-01549" : "VUID-vkCmdCopyImage-None-01549";
1688-
std::stringstream ss;
1688+
std::ostringstream ss;
16891689
ss << "srcImage format " << string_VkFormat(src_plane_format);
16901690
if (is_src_multiplane) {
16911691
ss << " (which is the compatible format for plane "
@@ -2131,7 +2131,7 @@ bool CoreChecks::ValidateBufferBounds(const vvl::CommandBuffer &cb_state, const
21312131

21322132
if (buffer_state.create_info.size < buffer_copy_size) {
21332133
const LogObjectList objlist(cb_state.Handle(), buffer_state.Handle(), image_state.Handle());
2134-
std::stringstream ss;
2134+
std::ostringstream ss;
21352135
ss << "is trying to copy " << buffer_copy_size << " bytes to/from the (" << FormatHandle(buffer_state).c_str()
21362136
<< ") which exceeds the VkBuffer total size of " << buffer_state.create_info.size
21372137
<< " bytes.\nLast texel coordinate of the image is at {x = " << last_x << ", y = " << last_y << ", z = " << last_z
@@ -2678,7 +2678,7 @@ bool CoreChecks::ValidateMemoryImageCopyCommon(InfoPointer info_ptr, const Locat
26782678
bool CoreChecks::ValidateHostCopyImageCreateInfos(const vvl::Image &src_image_state, const vvl::Image &dst_image_state,
26792679
const Location &loc) const {
26802680
bool skip = false;
2681-
std::stringstream mismatch_stream{};
2681+
std::ostringstream mismatch_stream{};
26822682
const VkImageCreateInfo &src_info = src_image_state.create_info;
26832683
const VkImageCreateInfo &dst_info = dst_image_state.create_info;
26842684

@@ -2729,7 +2729,7 @@ bool CoreChecks::ValidateHostCopyImageCreateInfos(const vvl::Image &src_image_st
27292729
}
27302730

27312731
if (mismatch_stream.str().length() > 0) {
2732-
std::stringstream ss;
2732+
std::ostringstream ss;
27332733
ss << "The creation parameters for srcImage and dstImage differ:\n" << mismatch_stream.str();
27342734
LogObjectList objlist(src_image_state.Handle(), dst_image_state.Handle());
27352735
skip |= LogError("VUID-VkCopyImageToImageInfo-srcImage-09069", objlist, loc, "%s.", ss.str().c_str());
@@ -2751,7 +2751,7 @@ bool CoreChecks::ValidateHostCopyImageLayout(const VkImage image, const VkImageL
27512751
}
27522752
}
27532753

2754-
std::stringstream ss;
2754+
std::ostringstream ss;
27552755
ss << "is " << string_VkImageLayout(image_layout)
27562756
<< " which is not one of the layouts returned in VkPhysicalDeviceHostImageCopyPropertiesEXT::" << String(supported_name)
27572757
<< "[" << layout_count << "]\nList of supported layouts:\n";

layers/core_checks/cc_descriptor.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ bool CoreChecks::VerifyDescriptorSetLayoutIsCompatibile(const vvl::DescriptorSet
7171
// Check descriptor counts
7272
const auto bound_total_count = to_bind_ds_layout_def->GetTotalDescriptorCount();
7373
if (reference_ds_layout_def->GetTotalDescriptorCount() != to_bind_ds_layout_def->GetTotalDescriptorCount()) {
74-
std::stringstream error_str;
74+
std::ostringstream error_str;
7575
error_str << FormatHandle(reference_dsl_handle) << " from pipeline layout has "
7676
<< reference_ds_layout_def->GetTotalDescriptorCount() << " total descriptors, but "
7777
<< FormatHandle(to_bind_dsl_handle) << ", trying to bind, has " << bound_total_count << " total descriptors";
@@ -84,7 +84,7 @@ bool CoreChecks::VerifyDescriptorSetLayoutIsCompatibile(const vvl::DescriptorSet
8484
for (const auto [binding_index, layout_binding] : vvl::enumerate(reference_ds_layout_def->GetBindings())) {
8585
const auto bound_binding = to_bind_ds_layout_def->GetBindingInfoFromIndex((uint32_t)binding_index);
8686
if (layout_binding.descriptorCount != bound_binding->descriptorCount) {
87-
std::stringstream error_str;
87+
std::ostringstream error_str;
8888
error_str << "Binding " << layout_binding.binding << " for " << FormatHandle(reference_dsl_handle)
8989
<< " from pipeline layout has a descriptorCount of " << layout_binding.descriptorCount << " but binding "
9090
<< layout_binding.binding << " for " << FormatHandle(to_bind_dsl_handle)
@@ -96,15 +96,15 @@ bool CoreChecks::VerifyDescriptorSetLayoutIsCompatibile(const vvl::DescriptorSet
9696
error_msg = error_str.str();
9797
return false;
9898
} else if (layout_binding.descriptorType != bound_binding->descriptorType) {
99-
std::stringstream error_str;
99+
std::ostringstream error_str;
100100
error_str << "Binding " << layout_binding.binding << " for " << FormatHandle(reference_dsl_handle)
101101
<< " from pipeline layout is type " << string_VkDescriptorType(layout_binding.descriptorType)
102102
<< " but binding " << layout_binding.binding << " for " << FormatHandle(to_bind_dsl_handle)
103103
<< ", trying to bind, is type " << string_VkDescriptorType(bound_binding->descriptorType) << "";
104104
error_msg = error_str.str();
105105
return false;
106106
} else if (layout_binding.stageFlags != bound_binding->stageFlags) {
107-
std::stringstream error_str;
107+
std::ostringstream error_str;
108108
error_str << "Binding " << layout_binding.binding << " for " << FormatHandle(reference_dsl_handle)
109109
<< " from pipeline layout has stageFlags " << string_VkShaderStageFlags(layout_binding.stageFlags)
110110
<< " but binding " << layout_binding.binding << " for " << FormatHandle(to_bind_dsl_handle)
@@ -121,7 +121,7 @@ bool CoreChecks::VerifyDescriptorSetLayoutIsCompatibile(const vvl::DescriptorSet
121121
}
122122

123123
if (reference_ds_layout_def->GetCreateFlags() != to_bind_ds_layout_def->GetCreateFlags()) {
124-
std::stringstream error_str;
124+
std::ostringstream error_str;
125125
error_str << FormatHandle(reference_dsl_handle) << " from pipeline layout was created with ("
126126
<< string_VkDescriptorSetLayoutCreateFlags(reference_ds_layout_def->GetCreateFlags()) << "), but "
127127
<< FormatHandle(to_bind_dsl_handle) << ", trying to bind, has ("
@@ -134,7 +134,7 @@ bool CoreChecks::VerifyDescriptorSetLayoutIsCompatibile(const vvl::DescriptorSet
134134
const auto &ds_layout_flags = reference_ds_layout_def->GetBindingFlags();
135135
const auto &bound_layout_flags = to_bind_ds_layout_def->GetBindingFlags();
136136
if (bound_layout_flags != ds_layout_flags) {
137-
std::stringstream error_str;
137+
std::ostringstream error_str;
138138
assert(ds_layout_flags.size() == bound_layout_flags.size());
139139
size_t i;
140140
for (i = 0; i < ds_layout_flags.size(); i++) {
@@ -1416,7 +1416,7 @@ bool CoreChecks::ValidateImageUpdate(const vvl::ImageView &view_state, VkImageLa
14161416
default:
14171417
break;
14181418
}
1419-
std::stringstream error_str;
1419+
std::ostringstream error_str;
14201420
error_str << "Descriptor update with descriptorType " << string_VkDescriptorType(type)
14211421
<< " is being updated with invalid imageLayout " << string_VkImageLayout(image_layout) << " for image "
14221422
<< FormatHandle(image_state->Handle()) << " in imageView " << FormatHandle(view_state.Handle())
@@ -1790,7 +1790,7 @@ bool CoreChecks::ValidateWriteUpdate(const vvl::DescriptorSet &dst_set, const Vk
17901790
// stageFlags
17911791
if (current_binding->count > 0) {
17921792
if (current_binding->type != descriptor_type) {
1793-
std::stringstream extra;
1793+
std::ostringstream extra;
17941794
// If using inline, easy to go outside of its range and not realize you are in the next descriptor
17951795
if (descriptor_type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK) {
17961796
extra << "\nFor inline uniforms blocks, you might have your VkWriteDescriptorSet::dstArrayElement ("
@@ -2826,7 +2826,7 @@ bool CoreChecks::PreCallValidateCmdBindDescriptorBuffersEXT(VkCommandBuffer comm
28262826

28272827
auto list_buffers = [this](std::vector<VkBuffer> &buffer_list) {
28282828
vvl::unordered_set<VkBuffer> unique_buffers;
2829-
std::stringstream msg;
2829+
std::ostringstream msg;
28302830
for (const VkBuffer &buffer : buffer_list) {
28312831
msg << FormatHandle(buffer) << '\n';
28322832
unique_buffers.insert(buffer);
@@ -3234,7 +3234,7 @@ bool CoreChecks::ValidateDescriptorAddressInfoTexelBufferAlignment(const VkDescr
32343234
alignment_requirement = std::min(alignment_requirement, texel_block_size);
32353235
}
32363236
if (!IsPointerAligned(address_info.address, alignment_requirement)) {
3237-
std::stringstream ss;
3237+
std::ostringstream ss;
32383238
ss << "(0x" << std::hex << address_info.address << std::dec << ") must be aligned to " << alignment_requirement << "\n";
32393239
if (phys_dev_props_core13.storageTexelBufferOffsetSingleTexelAlignment) {
32403240
ss << "storageTexelBufferOffsetSingleTexelAlignment is VK_TRUE, so we take "
@@ -3260,7 +3260,7 @@ bool CoreChecks::ValidateDescriptorAddressInfoTexelBufferAlignment(const VkDescr
32603260
alignment_requirement = std::min(alignment_requirement, texel_block_size);
32613261
}
32623262
if (!IsPointerAligned(address_info.address, alignment_requirement)) {
3263-
std::stringstream ss;
3263+
std::ostringstream ss;
32643264
ss << "(0x" << std::hex << address_info.address << std::dec << ") must be a aligned to " << alignment_requirement
32653265
<< "\n";
32663266
if (phys_dev_props_core13.uniformTexelBufferOffsetSingleTexelAlignment) {

0 commit comments

Comments
 (0)