Graphics
Intel® graphics drivers and software, compatibility, troubleshooting, performance, and optimization
20598 Discussions

SDL 2.0.10 Floating Point Precision Texture Rendering draws 1 row of excess pixels above and to the left of the image onscreen

Stanton__Nicholas
6,992 Views

https://software.intel.com/en-us/forums/graphics-driver-bug-reporting/topic/820664
-------------------------------
System Setup Information:
-------------------------------
System: Intel NUC7i3BNK
CPU: i3-7100U (Intel(R) Core(TM) i3-7100U CPU @ 2.40GHz (4 CPUs), ~2.4GHz)
GPU: HD620 (Intel HD Graphics 620)
Graphics Driver Version: 24.20.100.6286
System BIOS Version: BNKBL357.86A.0080.2019.0725.1139
Operating System: Windows 10 Pro 64-bit
OS Version: 1903
OpenGL Version: 4.5 (Build 24.20.100.6286)
SDL Version: 2.0.10
SDL_image Version: 2.0.5
API: SDL (uses OpenGL)
Occurs on Non-Intel GPU?: No (a separate computer with an AMD graphics card did not experience this issue)
Processor Line: N/A
CMOS Setting: N/A
GOP/VBIOS Version: N/A
-------------------------------
Steps to Reproduce:
-------------------------------
Summary
1. Using SDL 2.0.10, initialize sdl, sdl_image, a window, and renderer with lower logical resolution than window resolution
2. Load a PNG file into a texture
3. Define clipRect whose y value is not at the top of the image or the left of the imaeg, and whose pixels have different colors than the pixels at y-1 and x-1
4. Define destRect whose x and y values are floats with non-zero decimal values, whose w and h values are same as clip rectangle's w and h.
5. Draw the texture to the screen with the defined clip and destination rectangles using SDL_RenderCopyExF(renderer, texture, clipRect, destRectF, 0.0, NULL, SDL_FLIP_NONE)
Steps
1. Download SDL 2.0.10 from https://www.libsdl.org/download-2.0.php
3. Download SDL_image 2.0.5 from https://www.libsdl.org/projects/SDL_image/
3. Download the Codeblocks IDE from http://www.codeblocks.org/downloads
4. Create a new "Codeblocks Project"
5. Instructions to setup the project with SDL can be found in Lesson 1 and Lesson 6 of a tutorial at http://lazyfoo.net/tutorials/SDL/index.php (dll files can be included in the root folder of the project)
6. Create a folder in the root project folder titled png
7. Put the attached "Test.png" file into the png folder created above
8. Create "main.cpp" C++ source file File -> New -> File -> C/C++ Source
9. Copy the Code found in bottom section "Code" into the main.cpp fie
10. Compile the program with ctrl+f9 and run with f9
Code
#include "SDL.h"
#include "SDL_image.h"
int main(int argc, char* args[]) {
SDL_Init(SDL_INIT_VIDEO);
SDL_Window* window = SDL_CreateWindow("Title", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 1152, 648, SDL_WINDOW_SHOWN);
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
SDL_RenderSetLogicalSize(renderer, 384, 216);
IMG_Init(IMG_INIT_PNG);
SDL_Surface* loadedSurface = IMG_Load("png/Test.png");
SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, loadedSurface);
SDL_Rect* clipRect = new SDL_Rect();
clipRect->x = 1; clipRect->y = 1; clipRect->w = 37; clipRect->h = 110;
SDL_FRect* destRectF = new SDL_FRect();
destRectF->x = 30.5f; destRectF->y = 90.5f; destRectF->w = 37.0f; destRectF->h = 110.0f;
SDL_RenderClear(renderer);
SDL_RenderCopyExF(renderer, texture, clipRect, destRectF, 0.0, NULL, SDL_FLIP_NONE);
SDL_RenderPresent(renderer);
SDL_Delay(5000);
return 0; }
-------------------------------
Expected Results
-------------------------------
When using floating point precision rendering, the image is drawn without any excess pixels drawn. See "Expected.jpg".
-------------------------------
Actual Results
-------------------------------
When using floating point precision rendering, excess pixels not defined in the clipping rectangle are drawn above and to the left of where the image is drawn on screen. See "Issue.jpg". Specifically, at the screen position destRect->y - 1, the pixels in the image at clipRect->y - 1 are drawn onto the screen. Similarly, at the screen position destRect->x - 1, the pixels in the image at clipRect->x -1 are drawn onto the screen.

"Test.png" has a border of bright green pixels with some blue pixels all around it. This border is not included in the clip rectangle of the code, but it is being drawn above and to the left of the image.

This bug occurs 100% of the time.
-------------------------------
Additional Notes
-------------------------------
The bug only occurs when the destination rectangle's y value or x value have a non-zero decimal value. If only the y value has non-zero decimal, only the top has excess pixels drawn. Similarly, if only the x value has non-zero decimal, only the left excess pixels are drawn. If the same code above is run except destRect->x = 30.0f and destRect->y = 90.0f , the bug will not occur.
Excess pixels are never drawn to the right of the image nor below the image. 
The excess pixels are the size of the window pixels, not the size of the logical resolution pixels of the drawn image.
"Test.png" is png drawn from image editor while "Issue.jpg" and "Expected.jpg" are just from snipping tool, which why they have slight distortions. Issue having 1/2 of the bright green / blue border is the issue (not the other small distortions from snipping tool).
I have used Intel Driver and Support Assistant to keep my computer up to date
This bug has occured on another computer with Intel HD Graphics (not 620), and has been around for at-least a year and a half. I did not report is earlier as I was using SDL 2.0.5 with an unofficial add-on library SDL_gpu, though after switching my code to SDL 2.0.10 and dropping SDL_gpu, I noticed the bug has remained the same (I believe these code bases used the same openGL logic for floating point precision rendering). 
Thank you so much for considering my bug. I have loved my NUC, this small issue is the only problem I've had. If there's anything else you need from me, please let me know.

0 Kudos
0 Replies
Reply