mirror of
				https://github.com/libsdl-org/SDL.git
				synced 2025-11-04 01:34:38 +00:00 
			
		
		
		
	renderer: always update the output pixel size at startup
Fixes https://github.com/libsdl-org/SDL/issues/10990
This commit is contained in:
		@@ -735,7 +735,9 @@ static void UpdateMainViewDimensions(SDL_Renderer *renderer)
 | 
			
		||||
    if (renderer->window) {
 | 
			
		||||
        SDL_GetWindowSize(renderer->window, &window_w, &window_h);
 | 
			
		||||
    }
 | 
			
		||||
    SDL_GetRenderOutputSize(renderer, &renderer->main_view.pixel_w, &renderer->main_view.pixel_h);
 | 
			
		||||
    SDL_GetRenderOutputSize(renderer, &renderer->output_pixel_w, &renderer->output_pixel_h);
 | 
			
		||||
    renderer->main_view.pixel_w = renderer->output_pixel_w;
 | 
			
		||||
    renderer->main_view.pixel_h = renderer->output_pixel_h;
 | 
			
		||||
    if (window_w > 0 && window_h > 0) {
 | 
			
		||||
        renderer->dpi_scale.x = (float)renderer->main_view.pixel_w / window_w;
 | 
			
		||||
        renderer->dpi_scale.y = (float)renderer->main_view.pixel_h / window_h;
 | 
			
		||||
@@ -2565,9 +2567,6 @@ static void UpdateLogicalPresentation(SDL_Renderer *renderer)
 | 
			
		||||
    int iwidth, iheight;
 | 
			
		||||
    SDL_GetRenderOutputSize(renderer, &iwidth, &iheight);
 | 
			
		||||
 | 
			
		||||
    renderer->window_pixel_w = iwidth;
 | 
			
		||||
    renderer->window_pixel_h = iheight;
 | 
			
		||||
 | 
			
		||||
    const float output_w = (float)iwidth;
 | 
			
		||||
    const float output_h = (float)iheight;
 | 
			
		||||
    const float logical_w = renderer->logical_w;
 | 
			
		||||
@@ -2702,14 +2701,10 @@ bool SDL_GetRenderLogicalPresentationRect(SDL_Renderer *renderer, SDL_FRect *rec
 | 
			
		||||
        if (renderer->logical_presentation_mode == SDL_LOGICAL_PRESENTATION_DISABLED) {
 | 
			
		||||
            int output_w = 0, output_h = 0;
 | 
			
		||||
 | 
			
		||||
            if (!SDL_GetRenderOutputSize(renderer, &output_w, &output_h)) {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            rect->x = 0.0f;
 | 
			
		||||
            rect->y = 0.0f;
 | 
			
		||||
            rect->w = (float)output_w;
 | 
			
		||||
            rect->h = (float)output_h;
 | 
			
		||||
            rect->w = (float)renderer->output_pixel_w;
 | 
			
		||||
            rect->h = (float)renderer->output_pixel_h;
 | 
			
		||||
        } else {
 | 
			
		||||
            SDL_copyp(rect, &renderer->logical_dst_rect);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -250,8 +250,8 @@ struct SDL_Renderer
 | 
			
		||||
    SDL_RenderViewState *view;
 | 
			
		||||
    SDL_RenderViewState main_view;
 | 
			
		||||
 | 
			
		||||
    // Cache the window size in pixels
 | 
			
		||||
    int window_pixel_w, window_pixel_h;
 | 
			
		||||
    // Cache the output size in pixels
 | 
			
		||||
    int output_pixel_w, output_pixel_h;
 | 
			
		||||
 | 
			
		||||
    // The window pixel to point coordinate scale
 | 
			
		||||
    SDL_FPoint dpi_scale;
 | 
			
		||||
 
 | 
			
		||||
@@ -976,16 +976,16 @@ static bool GPU_RenderPresent(SDL_Renderer *renderer)
 | 
			
		||||
    blit_info.source.w = data->backbuffer.width;
 | 
			
		||||
    blit_info.source.h = data->backbuffer.height;
 | 
			
		||||
    blit_info.destination.texture = swapchain;
 | 
			
		||||
    blit_info.destination.w = renderer->window_pixel_w;
 | 
			
		||||
    blit_info.destination.h = renderer->window_pixel_h;
 | 
			
		||||
    blit_info.destination.w = renderer->output_pixel_w;
 | 
			
		||||
    blit_info.destination.h = renderer->output_pixel_h;
 | 
			
		||||
    blit_info.load_op = SDL_GPU_LOADOP_DONT_CARE;
 | 
			
		||||
    blit_info.filter = SDL_GPU_FILTER_LINEAR;
 | 
			
		||||
 | 
			
		||||
    SDL_BlitGPUTexture(data->state.command_buffer, &blit_info);
 | 
			
		||||
 | 
			
		||||
    if (renderer->window_pixel_w != data->backbuffer.width || renderer->window_pixel_h != data->backbuffer.height || swapchain_fmt != data->backbuffer.format) {
 | 
			
		||||
    if (renderer->output_pixel_w != data->backbuffer.width || renderer->output_pixel_h != data->backbuffer.height || swapchain_fmt != data->backbuffer.format) {
 | 
			
		||||
        SDL_ReleaseGPUTexture(data->device, data->backbuffer.texture);
 | 
			
		||||
        CreateBackbuffer(data, renderer->window_pixel_w, renderer->window_pixel_h, swapchain_fmt);
 | 
			
		||||
        CreateBackbuffer(data, renderer->output_pixel_w, renderer->output_pixel_h, swapchain_fmt);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
// *** FIXME ***
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user