Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cast a float result back to uint32_t #1241

Merged

Conversation

bradgrantham-lunarg
Copy link
Contributor

No description provided.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build queued with queue ID 33175.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 3150 running.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 3150 failed.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build queued with queue ID 33188.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 3151 running.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 3151 passed.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build queued with queue ID 33276.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 3153 running.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 3153 passed.

@panos-lunarg panos-lunarg self-requested a review August 30, 2023 07:22
@@ -2147,12 +2147,12 @@ void VulkanReplayConsumerBase::WriteScreenshots(const Decoded_VkPresentInfoKHR*
// If both copy_scale and copy_width are provided, use copy_scale.
const uint32_t screenshot_width =
options_.screenshot_scale
? (options_.screenshot_scale * swapchain_info->width)
? static_cast<uint32_t>(options_.screenshot_scale * swapchain_info->width)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constexpr uint32_t truncate_to_uint32(const float f)
{
    GFXRECON_ASSERT_DEBUG(f >= 0.0f);
    return static_cast<uint32_t>(f);
}

somewhere in a util header to name what we are doing here and add the sanity precondition check on the param?

Copy link
Contributor Author

@bradgrantham-lunarg bradgrantham-lunarg Aug 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read static_cast<uint32> on float as truncating so for my taste there's not much reason to have a function that has that name. (To me it would be like a function called "copy_string" that calls "strcpy".)

This PR is just to fix warnings in /W3 build in Visual C++, but -

It does seem like a good idea to check the range of the scale but that should probably be validated in input. Want to add that in a PR?

@bradgrantham-lunarg bradgrantham-lunarg merged commit 8c5e98e into LunarG:dev Aug 30, 2023
5 checks passed
davidlunarg pushed a commit to davidlunarg/gfxreconstruct that referenced this pull request Aug 30, 2023
* cast a float result back to uint32_t

* fix some strict warnings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants