28 std::shared_ptr<Texture> destination,
29 std::optional<IRect> source_region,
31 std::string_view label) {
33 VALIDATION_LOG <<
"Attempted to add a texture blit with no source.";
37 VALIDATION_LOG <<
"Attempted to add a texture blit with no destination.";
41 if (source->GetTextureDescriptor().sample_count !=
42 destination->GetTextureDescriptor().sample_count) {
44 "The source sample count ({}) must match the destination sample count "
46 static_cast<int>(source->GetTextureDescriptor().sample_count),
47 static_cast<int>(destination->GetTextureDescriptor().sample_count));
50 if (source->GetTextureDescriptor().format !=
51 destination->GetTextureDescriptor().format) {
53 "The source pixel format ({}) must match the destination pixel format "
61 if (!source_region.has_value()) {
68 if (!source_region.has_value()) {
73 std::move(source), std::move(destination), source_region.value(),
74 destination_origin, label);
78 std::shared_ptr<DeviceBuffer> destination,
79 std::optional<IRect> source_region,
80 size_t destination_offset,
81 std::string_view label) {
83 VALIDATION_LOG <<
"Attempted to add a texture blit with no source.";
87 VALIDATION_LOG <<
"Attempted to add a texture blit with no destination.";
91 if (!source_region.has_value()) {
95 auto bytes_per_pixel =
97 auto bytes_per_image = source_region->Area() * bytes_per_pixel;
98 if (destination_offset + bytes_per_image >
99 destination->GetDeviceBufferDescriptor().size) {
101 <<
"Attempted to add a texture blit with out of bounds access.";
108 if (!source_region.has_value()) {
113 source_region.value(), destination_offset,
118 std::shared_ptr<Texture> destination,
119 std::optional<IRect> destination_region,
120 std::string_view label,
123 bool convert_to_read) {
125 VALIDATION_LOG <<
"Attempted to add a texture blit with no destination.";
128 ISize destination_size = destination->GetSize();
129 IRect destination_region_value =
131 if (destination_region_value.
GetX() < 0 ||
132 destination_region_value.
GetY() < 0 ||
133 destination_region_value.
GetRight() > destination_size.
width ||
135 VALIDATION_LOG <<
"Blit region cannot be larger than destination texture.";
139 auto bytes_per_pixel =
141 auto bytes_per_region = destination_region_value.
Area() * bytes_per_pixel;
145 <<
"Attempted to add a texture blit with out of bounds access.";
148 if (mip_level >= destination->GetMipCount()) {
149 VALIDATION_LOG <<
"Invalid value for mip_level: " << mip_level <<
". "
150 <<
"The destination texture has "
151 << destination->GetMipCount() <<
" mip levels.";
160 destination_region_value, label,
161 mip_level, slice, convert_to_read);
165 const std::shared_ptr<Texture>&
texture) {
170 std::string_view label) {
172 VALIDATION_LOG <<
"Attempted to add an invalid mipmap generation command "
void SetLabel(std::string_view label)
bool AddCopy(std::shared_ptr< Texture > source, std::shared_ptr< Texture > destination, std::optional< IRect > source_region=std::nullopt, IPoint destination_origin={}, std::string_view label="")
Record a command to copy the contents of one texture to another texture. The blit area is limited by ...
virtual bool OnCopyTextureToTextureCommand(std::shared_ptr< Texture > source, std::shared_ptr< Texture > destination, IRect source_region, IPoint destination_origin, std::string_view label)=0
bool GenerateMipmap(std::shared_ptr< Texture > texture, std::string_view label="")
Record a command to generate all mip levels for a texture.
virtual bool OnGenerateMipmapCommand(std::shared_ptr< Texture > texture, std::string_view label)=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 bool OnCopyBufferToTextureCommand(BufferView source, std::shared_ptr< Texture > destination, IRect destination_region, std::string_view label, uint32_t mip_level, uint32_t slice, bool convert_to_read)=0
virtual bool OnCopyTextureToBufferCommand(std::shared_ptr< Texture > source, std::shared_ptr< DeviceBuffer > destination, IRect source_region, size_t destination_offset, std::string_view label)=0
virtual void OnSetLabel(std::string_view label)=0
constexpr size_t BytesPerPixelForPixelFormat(PixelFormat format)
constexpr const char * PixelFormatToString(PixelFormat format)
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|.
constexpr auto GetRight() const
static constexpr TRect MakeSize(const TSize< U > &size)