Re: Truecolor software rendering
Posted: Sun Jun 05, 2016 9:39 am
I've checked in a fix now. Let me know if there's any more issues.
dpJudas wrote: The main catch is that some of the drawers does an additional lookup into a dc_translation table. And then there is DrawShadedColumn where it uses colormap as some kind of alpha table lookup. If the column data returned is no longer an index, those additional lookups will not work. Unfortunately I do not know at this time why exactly those two things are needed. With the translation table I have a theory its about the hue adjustment for the player - with the alpha table lookup I have no idea. There are also some masked shaders that skip palette index 0, but I suppose those could just switch to an alpha test instead.
dpJudas wrote: None of the drawers currently use the alpha channel (except for those first doing a translation lookup). Adding the code for it should be straightforward enough, but I'm a little bit worried about the performance impact.
Code: Select all
/home/edward-san/zdoom/branch/truecolor/src/./r_draw.h:514:7: error: no type
named 'condition_variable' in namespace 'std'
std::condition_variable start_condition;
~~~~~^
/home/edward-san/zdoom/branch/truecolor/src/./r_draw.h:520:7: error: no type
named 'condition_variable' in namespace 'std'
std::condition_variable end_condition;
~~~~~^
/home/edward-san/zdoom/branch/truecolor/src/r_segs.cpp:1183:10: error: no member
named 'floor' in namespace 'std'; did you mean simply 'floor'?
v = v - std::floor(v);
^~~~~~~~~~
floor
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:184:14: note: 'floor' declared
here
__MATHCALLX (floor,, (_Mdouble_ __x), (__const__));
^
Code: Select all
/home/edward-san/zdoom/branch/truecolor/src/r_draw_rgba.cpp:115:77: warning:
comparison of integers of different signs: 'int' and 'size_type'
(aka 'unsigned long') [-Wsign-compare]
...[&]() { return queue->finished_threads == queue->threads.size(); });
~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~
/home/edward-san/zdoom/branch/truecolor/src/r_draw_rgba.cpp:1657:9: warning:
explicitly assigning value of variable of type 'int' to itself
[-Wself-assign]
ds_x2 = ::ds_x2;
~~~~~ ^ ~~~~~~~
/home/edward-san/zdoom/branch/truecolor/src/r_draw_rgba.cpp:1759:9: warning:
explicitly assigning value of variable of type 'int' to itself
[-Wself-assign]
ds_x2 = ::ds_x2;
~~~~~ ^ ~~~~~~~
/home/edward-san/zdoom/branch/truecolor/src/r_draw_rgba.cpp:1880:9: warning:
explicitly assigning value of variable of type 'int' to itself
[-Wself-assign]
ds_x2 = ::ds_x2;
~~~~~ ^ ~~~~~~~
/home/edward-san/zdoom/branch/truecolor/src/r_draw_rgba.cpp:2011:9: warning:
explicitly assigning value of variable of type 'int' to itself
[-Wself-assign]
ds_x2 = ::ds_x2;
~~~~~ ^ ~~~~~~~
/home/edward-san/zdoom/branch/truecolor/src/r_draw_rgba.cpp:2132:9: warning:
explicitly assigning value of variable of type 'int' to itself
[-Wself-assign]
ds_x2 = ::ds_x2;
~~~~~ ^ ~~~~~~~
Code: Select all
=================================================================
==12747==ERROR: AddressSanitizer: heap-use-after-free on address 0x6300003e0400 at pc 0x000000626f7c bp 0x7ffc8f724bf0 sp 0x7ffc8f724be0
READ of size 1 at 0x6300003e0400 thread T0
#0 0x626f7b in DrawColumnHorizRGBACommand::Execute(DrawerThread*) /home/edward-san/zdoom/branch/truecolor/src/r_drawt_rgba.cpp:1543
#1 0x5d11fc in DrawerCommandQueue::Finish() /home/edward-san/zdoom/branch/truecolor/src/r_draw_rgba.cpp:109
#2 0x5d1ffa in R_FinishDrawerCommands() /home/edward-san/zdoom/branch/truecolor/src/r_draw_rgba.cpp:3428
#3 0x5b2e39 in FSoftwareRenderer::RenderView(player_t*) /home/edward-san/zdoom/branch/truecolor/src/r_swrenderer.cpp:168
#4 0x88fa95 in D_Display() /home/edward-san/zdoom/branch/truecolor/src/d_main.cpp:770
#5 0x891a1c in D_DoomLoop() /home/edward-san/zdoom/branch/truecolor/src/d_main.cpp:1013
#6 0x898bb6 in D_DoomMain() /home/edward-san/zdoom/branch/truecolor/src/d_main.cpp:2642
#7 0x5a740d in main /home/edward-san/zdoom/branch/truecolor/src/posix/sdl/i_main.cpp:317
#8 0x7f3548048abf in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20abf)
#9 0x598628 in _start (/home/edward-san/zdoom/branch/truecolor/debug/gcc/zdoom+0x598628)
0x6300003e0400 is located 0 bytes inside of 64056-byte region [0x6300003e0400,0x6300003efe38)
freed by thread T0 here:
#0 0x7f354b34b02a in operator delete[](void*) (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9a02a)
#1 0xeaee56 in FPatchTexture::Unload() /home/edward-san/zdoom/branch/truecolor/src/textures/patchtexture.cpp:184
#2 0x5b2632 in FSoftwareRenderer::PrecacheTexture(FTexture*, int) /home/edward-san/zdoom/branch/truecolor/src/r_swrenderer.cpp:97
#3 0x5b2c55 in FSoftwareRenderer::Precache(unsigned char*, TMap<PClassActor*, bool, THashTraits<PClassActor*>, TValueTraits<bool> >&) /home/edward-san/zdoom/branch/truecolor/src/r_swrenderer.cpp:147
#4 0xb30c41 in P_PrecacheLevel /home/edward-san/zdoom/branch/truecolor/src/p_setup.cpp:3441
#5 0xb34416 in P_SetupLevel(char const*, int) /home/edward-san/zdoom/branch/truecolor/src/p_setup.cpp:4174
#6 0x92089f in G_DoLoadLevel(int, bool) /home/edward-san/zdoom/branch/truecolor/src/g_level.cpp:972
#7 0x91e15f in G_InitNew(char const*, bool) /home/edward-san/zdoom/branch/truecolor/src/g_level.cpp:509
#8 0x91d117 in G_DoNewGame() /home/edward-san/zdoom/branch/truecolor/src/g_level.cpp:334
#9 0x9102d9 in G_Ticker() /home/edward-san/zdoom/branch/truecolor/src/g_game.cpp:1067
#10 0x8a56ad in TryRunTics() /home/edward-san/zdoom/branch/truecolor/src/d_net.cpp:1945
#11 0x891a12 in D_DoomLoop() /home/edward-san/zdoom/branch/truecolor/src/d_main.cpp:1009
#12 0x898bb6 in D_DoomMain() /home/edward-san/zdoom/branch/truecolor/src/d_main.cpp:2642
#13 0x5a740d in main /home/edward-san/zdoom/branch/truecolor/src/posix/sdl/i_main.cpp:317
#14 0x7f3548048abf in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20abf)
previously allocated by thread T0 here:
#0 0x7f354b34aa32 in operator new[](unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x99a32)
#1 0xeaf98e in FPatchTexture::MakeTexture() /home/edward-san/zdoom/branch/truecolor/src/textures/patchtexture.cpp:310
#2 0xeaefee in FPatchTexture::GetColumn(unsigned int, FTexture::Span const**) /home/edward-san/zdoom/branch/truecolor/src/textures/patchtexture.cpp:214
#3 0xc04af9 in DCanvas::DrawTextureParms(FTexture*, DrawParms&) /home/edward-san/zdoom/branch/truecolor/src/v_draw.cpp:310
#4 0xc033ce in DCanvas::DrawTexture(FTexture*, double, double, int, ...) /home/edward-san/zdoom/branch/truecolor/src/v_draw.cpp:121
#5 0x846ac0 in C_DrawConsole(bool) /home/edward-san/zdoom/branch/truecolor/src/c_console.cpp:870
#6 0x88f69e in D_Display() /home/edward-san/zdoom/branch/truecolor/src/d_main.cpp:752
#7 0x891a1c in D_DoomLoop() /home/edward-san/zdoom/branch/truecolor/src/d_main.cpp:1013
#8 0x898bb6 in D_DoomMain() /home/edward-san/zdoom/branch/truecolor/src/d_main.cpp:2642
#9 0x5a740d in main /home/edward-san/zdoom/branch/truecolor/src/posix/sdl/i_main.cpp:317
#10 0x7f3548048abf in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20abf)
SUMMARY: AddressSanitizer: heap-use-after-free /home/edward-san/zdoom/branch/truecolor/src/r_drawt_rgba.cpp:1543 DrawColumnHorizRGBACommand::Execute(DrawerThread*)
Shadow bytes around the buggy address:
0x0c6080074030: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c6080074040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c6080074050: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c6080074060: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c6080074070: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c6080074080:[fd]fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x0c6080074090: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x0c60800740a0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x0c60800740b0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x0c60800740c0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x0c60800740d0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Heap right redzone: fb
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack partial redzone: f4
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
==12747==AddressSanitizer: while reporting a bug found another one. Ignoring.
==12747==AddressSanitizer: while reporting a bug found another one. Ignoring.
==12747==AddressSanitizer: while reporting a bug found another one. Ignoring.
==12747==ABORTING
Terminated sig=0x0d
Code: Select all
=================================================================
==12763==ERROR: AddressSanitizer: heap-use-after-free on address 0x61200018a5b9 at pc 0x0000005dcf88 bp 0x7ffd64e83200 sp 0x7ffd64e831f0
READ of size 1 at 0x61200018a5b9 thread T0
==12763==AddressSanitizer: while reporting a bug found another one. Ignoring.
==12763==AddressSanitizer: while reporting a bug found another one. Ignoring.
==12763==AddressSanitizer: while reporting a bug found another one. Ignoring.
#0 0x5dcf87 in DrawShadedColumnRGBACommand::Execute(DrawerThread*) (/home/edward-san/zdoom/branch/truecolor/debug/gcc/zdoom+0x5dcf87)
#1 0x5d11fc in DrawerCommandQueue::Finish() /home/edward-san/zdoom/branch/truecolor/src/r_draw_rgba.cpp:109
#2 0x5d1ffa in R_FinishDrawerCommands() /home/edward-san/zdoom/branch/truecolor/src/r_draw_rgba.cpp:3428
#3 0x5b2e39 in FSoftwareRenderer::RenderView(player_t*) /home/edward-san/zdoom/branch/truecolor/src/r_swrenderer.cpp:168
#4 0x88fa95 in D_Display() /home/edward-san/zdoom/branch/truecolor/src/d_main.cpp:770
#5 0x891a1c in D_DoomLoop() /home/edward-san/zdoom/branch/truecolor/src/d_main.cpp:1013
#6 0x898bb6 in D_DoomMain() /home/edward-san/zdoom/branch/truecolor/src/d_main.cpp:2642
#7 0x5a740d in main /home/edward-san/zdoom/branch/truecolor/src/posix/sdl/i_main.cpp:317
#8 0x7f01f0e8fabf in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20abf)
#9 0x598628 in _start (/home/edward-san/zdoom/branch/truecolor/debug/gcc/zdoom+0x598628)
0x61200018a5b9 is located 121 bytes inside of 289-byte region [0x61200018a540,0x61200018a661)
freed by thread T0 here:
#0 0x7f01f419202a in operator delete[](void*) (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9a02a)
#1 0xeb6aa4 in FPNGTexture::Unload() /home/edward-san/zdoom/branch/truecolor/src/textures/pngtexture.cpp:374
#2 0xdfefc4 in ST_LoadCrosshair(bool) /home/edward-san/zdoom/branch/truecolor/src/g_shared/shared_sbar.cpp:167
#3 0x88ef98 in D_Display() /home/edward-san/zdoom/branch/truecolor/src/d_main.cpp:682
#4 0x891a1c in D_DoomLoop() /home/edward-san/zdoom/branch/truecolor/src/d_main.cpp:1013
#5 0x898bb6 in D_DoomMain() /home/edward-san/zdoom/branch/truecolor/src/d_main.cpp:2642
#6 0x5a740d in main /home/edward-san/zdoom/branch/truecolor/src/posix/sdl/i_main.cpp:317
#7 0x7f01f0e8fabf in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20abf)
previously allocated by thread T0 here:
#0 0x7f01f4191a32 in operator new[](unsigned long) (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x99a32)
#1 0xeb7084 in FPNGTexture::MakeTexture() /home/edward-san/zdoom/branch/truecolor/src/textures/pngtexture.cpp:468
#2 0xeb6b3a in FPNGTexture::GetColumn(unsigned int, FTexture::Span const**) /home/edward-san/zdoom/branch/truecolor/src/textures/pngtexture.cpp:410
#3 0xc04c80 in DCanvas::DrawTextureParms(FTexture*, DrawParms&) /home/edward-san/zdoom/branch/truecolor/src/v_draw.cpp:320
#4 0xc033ce in DCanvas::DrawTexture(FTexture*, double, double, int, ...) /home/edward-san/zdoom/branch/truecolor/src/v_draw.cpp:121
#5 0xe03ed6 in DBaseStatusBar::DrawCrosshair() /home/edward-san/zdoom/branch/truecolor/src/g_shared/shared_sbar.cpp:1172
#6 0xe047d7 in DBaseStatusBar::Draw(EHudState) /home/edward-san/zdoom/branch/truecolor/src/g_shared/shared_sbar.cpp:1282
#7 0xdcd918 in DSBarInfo::Draw(EHudState) /home/edward-san/zdoom/branch/truecolor/src/g_shared/sbarinfo.cpp:1021
#8 0x890280 in D_Display() /home/edward-san/zdoom/branch/truecolor/src/d_main.cpp:807
#9 0x891a1c in D_DoomLoop() /home/edward-san/zdoom/branch/truecolor/src/d_main.cpp:1013
#10 0x898bb6 in D_DoomMain() /home/edward-san/zdoom/branch/truecolor/src/d_main.cpp:2642
#11 0x5a740d in main /home/edward-san/zdoom/branch/truecolor/src/posix/sdl/i_main.cpp:317
#12 0x7f01f0e8fabf in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20abf)
SUMMARY: AddressSanitizer: heap-use-after-free ??:0 DrawShadedColumnRGBACommand::Execute(DrawerThread*)
Shadow bytes around the buggy address:
0x0c2480029460: fd fd fd fd fd fd fd fd fd fd fd fa fa fa fa fa
0x0c2480029470: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
0x0c2480029480: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x0c2480029490: fd fd fd fd fd fd fd fd fd fd fd fd fa fa fa fa
0x0c24800294a0: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
=>0x0c24800294b0: fd fd fd fd fd fd fd[fd]fd fd fd fd fd fd fd fd
0x0c24800294c0: fd fd fd fd fd fd fd fd fd fd fd fd fd fa fa fa
0x0c24800294d0: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
0x0c24800294e0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x0c24800294f0: fd fd fd fd fd fd fd fd fd fd fd fa fa fa fa fa
0x0c2480029500: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Heap right redzone: fb
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack partial redzone: f4
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
==12763==ABORTING