Commit caea0ba5 by Alexis Hetu Committed by Alexis Hétu

Implement Image clear

Use the blitter to implement Image::clear. The image can be easily packed into a sw::Surface. For now, the surface is a temporary, but it may become a member in the future if it makes sense. Bug b/119620767 Change-Id: I122a321509dc8cc5b624ddd776bd9059eee0cbc4 Reviewed-on: https://swiftshader-review.googlesource.com/c/23109Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com>
parent 9fbaf697
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "VkDeviceMemory.hpp" #include "VkDeviceMemory.hpp"
#include "VkBuffer.hpp" #include "VkBuffer.hpp"
#include "VkImage.hpp" #include "VkImage.hpp"
#include "Device/Blitter.hpp"
#include "Device/Surface.hpp" #include "Device/Surface.hpp"
#include <cstring> #include <cstring>
...@@ -232,7 +233,28 @@ void Image::clear(const VkClearValue& clearValue, const VkRect2D& renderArea, co ...@@ -232,7 +233,28 @@ void Image::clear(const VkClearValue& clearValue, const VkRect2D& renderArea, co
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
UNIMPLEMENTED(); // Set the proper format for the clear value, as described here:
// https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#clears-values
VkFormat clearFormat = VK_FORMAT_R32G32B32A32_SFLOAT;
if(sw::Surface::isSignedNonNormalizedInteger(format))
{
clearFormat = VK_FORMAT_R32G32B32A32_SINT;
}
else if(sw::Surface::isUnsignedNonNormalizedInteger(format))
{
clearFormat = VK_FORMAT_R32G32B32A32_UINT;
}
const sw::Rect rect(renderArea.offset.x, renderArea.offset.y,
renderArea.offset.x + renderArea.extent.width,
renderArea.offset.y + renderArea.extent.height);
const sw::SliceRect dRect(rect);
sw::Surface* surface = sw::Surface::create(extent.width, extent.height, extent.depth, format,
Cast(deviceMemory)->getOffsetPointer(memoryOffset), rowPitchBytes(), slicePitchBytes());
sw::Blitter blitter;
blitter.clear((void*)clearValue.color.float32, clearFormat, surface, dRect, 0xF);
delete surface;
} }
} // namespace vk } // namespace vk
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment