Skip to content

Commit e9006c8

Browse files
committed
Add top-left upload helper and canonical glyph tests
1 parent fa7af67 commit e9006c8

2 files changed

Lines changed: 466 additions & 1 deletion

File tree

demo/demo_vrhi.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,13 @@ static void vrhi_upload_greyscale_rect_to_r8_texture( vhTexture texture, int tex
933933
vrhi_upload_rect_via_blit( texture, nvrhi::Format::R8_UNORM, x, dst_y_top_left, w, h, r8_pixels );
934934
}
935935

936+
static void vrhi_upload_top_left_greyscale_rect_to_r8_texture( vhTexture texture, int texture_height, int x, int y, int w, int h, const uint8_t* pixels )
937+
{
938+
const int dst_y_top_left = vrhi_bottom_left_to_top_left_y( texture_height, y, h );
939+
std::vector< uint8_t > r8_pixels( pixels, pixels + static_cast< size_t >( w ) * static_cast< size_t >( h ) );
940+
vrhi_upload_rect_via_blit( texture, nvrhi::Format::R8_UNORM, x, dst_y_top_left, w, h, r8_pixels );
941+
}
942+
936943
static bool vrhi_readback_texture_region( vhTexture texture, nvrhi::Format format, int texture_width, int texture_height, int x, int y, int w, int h, uint8_t* out_pixels )
937944
{
938945
if ( !vrhi_is_valid( texture ) || !out_pixels || x < 0 || y < 0 || w <= 0 || h <= 0 ) {
@@ -1053,7 +1060,7 @@ static void fontcache_drawcmd()
10531060
} else if ( dcall.pass == VE_FONTCACHE_FRAMEBUFFER_PASS_ATLAS_UPLOAD ) {
10541061
vrhi_ensure_cpu_atlas_page( dcall.atlas_page );
10551062
const uint8_t* texels = &drawlist->texels[ dcall.texel_offset ];
1056-
vrhi_upload_greyscale_rect_to_r8_texture(
1063+
vrhi_upload_top_left_greyscale_rect_to_r8_texture(
10571064
g_cpu_atlas_pages[ dcall.atlas_page ].texture,
10581065
VE_FONTCACHE_CPU_ATLAS_PAGE_SIZE,
10591066
static_cast< int >( dcall.upload_region_x ),

0 commit comments

Comments
 (0)