Skip to content

Commit 27b0135

Browse files
committed
Merge pull request #109995 from clayjohn/texture-error
Handle the case where VRS is a two byte per pixel format when creating default VRS texture
2 parents 674f1da + b0d7a24 commit 27b0135

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

servers/rendering/renderer_rd/storage_rd/texture_storage.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,10 @@ TextureStorage::TextureStorage() {
481481
tformat.usage_bits = RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_CAN_UPDATE_BIT | (vrs_supported ? RD::TEXTURE_USAGE_VRS_ATTACHMENT_BIT : 0);
482482
tformat.texture_type = RD::TEXTURE_TYPE_2D;
483483

484+
uint32_t pixel_size = RD::get_image_format_pixel_size(tformat.format);
484485
Vector<uint8_t> pv;
485-
pv.resize(4 * 4);
486-
for (int i = 0; i < 4 * 4; i++) {
486+
pv.resize(4 * 4 * pixel_size);
487+
for (int i = 0; i < pv.size(); i++) {
487488
pv.set(i, 0);
488489
}
489490

servers/rendering/rendering_device_commons.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,6 @@ class RenderingDeviceCommons : public Object {
987987

988988
static const uint32_t TEXTURE_SAMPLES_COUNT[TEXTURE_SAMPLES_MAX];
989989

990-
static uint32_t get_image_format_pixel_size(DataFormat p_format);
991990
static void get_compressed_image_format_block_dimensions(DataFormat p_format, uint32_t &r_w, uint32_t &r_h);
992991
uint32_t get_compressed_image_format_block_byte_size(DataFormat p_format) const;
993992
static uint32_t get_compressed_image_format_pixel_rshift(DataFormat p_format);
@@ -1009,6 +1008,12 @@ class RenderingDeviceCommons : public Object {
10091008
static uint32_t get_format_vertex_size(DataFormat p_format);
10101009

10111010
public:
1011+
/*****************/
1012+
/**** TEXTURE ****/
1013+
/*****************/
1014+
1015+
static uint32_t get_image_format_pixel_size(DataFormat p_format);
1016+
10121017
/****************/
10131018
/**** SHADER ****/
10141019
/****************/

0 commit comments

Comments
 (0)