27 std::shared_ptr<Texture> destination,
28 std::optional<IRect> source_region,
30 std::string_view label) {
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 std::move(source), std::move(destination), source_region.value(),
73 destination_origin, label);
77 std::shared_ptr<DeviceBuffer> destination,
78 std::optional<IRect> source_region,
79 size_t destination_offset,
80 std::string_view label) {
82 VALIDATION_LOG <<
"Attempted to add a texture blit with no source.";
86 VALIDATION_LOG <<
"Attempted to add a texture blit with no destination.";
90 if (!source_region.has_value()) {
94 auto bytes_per_pixel =
96 auto bytes_per_image = source_region->Area() * bytes_per_pixel;
97 if (destination_offset + bytes_per_image >
98 destination->GetDeviceBufferDescriptor().size) {
100 <<
"Attempted to add a texture blit with out of bounds access.";
107 if (!source_region.has_value()) {
112 source_region.value(), destination_offset,
117 std::shared_ptr<Texture> destination,
118 std::optional<IRect> destination_region,
119 std::string_view label,
122 bool convert_to_read) {
124 VALIDATION_LOG <<
"Attempted to add a texture blit with no destination.";
127 ISize destination_size = destination->GetSize();
128 IRect destination_region_value =
130 if (destination_region_value.
GetX() < 0 ||
131 destination_region_value.
GetY() < 0 ||
132 destination_region_value.
GetRight() > destination_size.
width ||
134 VALIDATION_LOG <<
"Blit region cannot be larger than destination texture.";
138 auto bytes_per_pixel =
140 auto bytes_per_region = destination_region_value.
Area() * bytes_per_pixel;
144 <<
"Attempted to add a texture blit with out of bounds access.";
147 if (mip_level >= destination->GetMipCount()) {
148 VALIDATION_LOG <<
"Invalid value for mip_level: " << mip_level <<
". "
149 <<
"The destination texture has "
150 << destination->GetMipCount() <<
" mip levels.";
159 destination_region_value, label,
160 mip_level, slice, convert_to_read);
164 const std::shared_ptr<Texture>& texture) {
169 std::string_view label) {
171 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)
std::string SPrintF(const char *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
constexpr static TRect MakeSize(const TSize< U > &size)