27 std::shared_ptr<Texture> destination,
28 std::optional<IRect> source_region,
32 VALIDATION_LOG <<
"Attempted to add a texture blit with no source.";
36 VALIDATION_LOG <<
"Attempted to add a texture blit with no destination.";
40 if (
source->GetTextureDescriptor().sample_count !=
41 destination->GetTextureDescriptor().sample_count) {
43 "The source sample count (%d) must match the destination sample count "
45 static_cast<int>(
source->GetTextureDescriptor().sample_count),
46 static_cast<int>(destination->GetTextureDescriptor().sample_count));
49 if (
source->GetTextureDescriptor().format !=
50 destination->GetTextureDescriptor().format) {
52 "The source pixel format (%s) must match the destination pixel format "
60 if (!source_region.has_value()) {
67 if (!source_region.has_value()) {
72 source_region = source_region->Intersection(
74 if (!source_region.has_value()) {
79 std::move(
source), std::move(destination), source_region.value(),
80 destination_origin, std::move(label));
84 std::shared_ptr<DeviceBuffer> destination,
85 std::optional<IRect> source_region,
86 size_t destination_offset,
89 VALIDATION_LOG <<
"Attempted to add a texture blit with no source.";
93 VALIDATION_LOG <<
"Attempted to add a texture blit with no destination.";
97 if (!source_region.has_value()) {
104 if (destination_offset + bytes_per_image >
105 destination->GetDeviceBufferDescriptor().size) {
107 <<
"Attempted to add a texture blit with out of bounds access.";
114 if (!source_region.has_value()) {
119 source_region.value(), destination_offset,
124 std::shared_ptr<Texture> destination,
125 std::optional<IRect> destination_region,
128 bool convert_to_read) {
130 VALIDATION_LOG <<
"Attempted to add a texture blit with no destination.";
133 ISize destination_size = destination->GetSize();
134 IRect destination_region_value =
136 if (destination_region_value.
GetX() < 0 ||
137 destination_region_value.
GetY() < 0 ||
138 destination_region_value.
GetRight() > destination_size.
width ||
140 VALIDATION_LOG <<
"Blit region cannot be larger than destination texture.";
148 if (
source.range.length != bytes_per_region) {
150 <<
"Attempted to add a texture blit with out of bounds access.";
159 destination_region_value,
160 std::move(label), slice, convert_to_read);
164 const std::shared_ptr<Texture>&
texture) {
171 VALIDATION_LOG <<
"Attempted to add an invalid mipmap generation command "
virtual bool OnCopyTextureToBufferCommand(std::shared_ptr< Texture > source, std::shared_ptr< DeviceBuffer > destination, IRect source_region, size_t destination_offset, std::string label)=0
bool AddCopy(std::shared_ptr< Texture > source, std::shared_ptr< Texture > destination, std::optional< IRect > source_region=std::nullopt, IPoint destination_origin={}, std::string label="")
Record a command to copy the contents of one texture to another texture. The blit area is limited by ...
bool GenerateMipmap(std::shared_ptr< Texture > texture, std::string label="")
Record a command to generate all mip levels for a texture.
void SetLabel(std::string label)
virtual bool OnCopyBufferToTextureCommand(BufferView source, std::shared_ptr< Texture > destination, IRect destination_region, std::string label, uint32_t slice, bool convert_to_read)=0
virtual bool ConvertTextureToShaderRead(const std::shared_ptr< Texture > &texture)
If the texture is not already in a shader read internal state, then convert it to that state.
virtual void OnSetLabel(std::string label)=0
virtual bool OnGenerateMipmapCommand(std::shared_ptr< Texture > texture, std::string label)=0
virtual bool OnCopyTextureToTextureCommand(std::shared_ptr< Texture > source, std::shared_ptr< Texture > destination, IRect source_region, IPoint destination_origin, std::string label)=0
constexpr size_t BytesPerPixelForPixelFormat(PixelFormat format)
std::string SPrintF(const char *format,...)
constexpr const char * PixelFormatToString(PixelFormat format)
static size_t bytes_per_pixel(skcms_PixelFormat fmt)
constexpr auto GetBottom() const
constexpr Type GetY() const
Returns the Y coordinate of the upper left corner, equivalent to |GetOrigin().y|.
constexpr T Area() const
Get the area of the rectangle, equivalent to |GetSize().Area()|.
constexpr Type GetX() const
Returns the X coordinate of the upper left corner, equivalent to |GetOrigin().x|.
static constexpr TRect MakeOriginSize(const TPoint< Type > &origin, const TSize< Type > &size)
constexpr auto GetRight() const
static constexpr TRect MakeSize(const TSize< U > &size)